更新 d01.md

main
lejings 4 weeks ago
parent ec2152335c
commit 64eb7401a5

@ -764,7 +764,77 @@ docker run ··· -v juming-nginx:/etc/nginx:rw nginx
> 构建镜像方式二:
通过脚本可以生成一些镜像,镜像是一层一层的,脚本一个个的命令,每个命令都是一层
``` shell
# 测试
FORM centos
VOLUME ["volume01","volume02']
CMD echo "-------end--------"
CMD /bin/bash
lejings@ljs-Ubuntu-desktop:~/docker-test-volume$ docker build -f dockerfile1 -t lejings/centos:1.0 .
[+] Building 0.2s (5/5) FINISHED docker:default
=> [internal] load build definition from dockerfile1 0.0s
=> => transferring dockerfile: 127B 0.0s
=> WARN: JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintende 0.0s
=> WARN: MultipleInstructionsDisallowed: Multiple CMD instructions should not be used 0.0s
=> WARN: JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintende 0.0s
=> [internal] load metadata for docker.io/library/centos:latest 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [1/1] FROM docker.io/library/centos:latest 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:139a93fd25c3b9efea4c67e8e980f34854181221323fec582204a1df00 0.0s
=> => naming to docker.io/lejings/centos:1.0 0.0s
3 warnings found (use docker --debug to expand):
- JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals (line 5)
- MultipleInstructionsDisallowed: Multiple CMD instructions should not be used in the same stage because only the last one will be used (line 5)
- JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals (line 6)
lejings@ljs-Ubuntu-desktop:~/docker-test-volume$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat-lejings-01 latest c00d1bfef336 9 days ago 474MB
tomcat latest f7737eeed429 3 weeks ago 468MB
tomcat 9.0 f05fe3cd4f92 3 weeks ago 470MB
redis latest 4075a3f8c3f8 3 weeks ago 117MB
portainer/portainer-ce latest 0c03664af9ed 6 weeks ago 308MB
nginx latest 9bea9f2796e2 2 months ago 192MB
mysql latest 56a8c14e1404 3 months ago 603MB
mysql 5.7 5107333e08a8 13 months ago 501MB
hello-world latest d2c94e258dcb 21 months ago 13.3kB
lejings/centos 1.0 139a93fd25c3 3 years ago 231MB
centos latest 5d0da3dc9764 3 years ago 231MB
# 生成镜像时自动挂载的目录
lejings@ljs-Ubuntu-desktop:~/docker-test-volume$ docker run -it 139a93fd25c3 /bin/bash
[root@e8b90b982a6e /]# ls -l
total 56
lrwxrwxrwx 1 root root 7 Nov 3 2020 bin -> usr/bin
drwxr-xr-x 5 root root 360 Jan 31 09:17 dev
drwxr-xr-x 1 root root 4096 Jan 31 09:17 etc
drwxr-xr-x 2 root root 4096 Nov 3 2020 home
lrwxrwxrwx 1 root root 7 Nov 3 2020 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Nov 3 2020 lib64 -> usr/lib64
drwx------ 2 root root 4096 Sep 15 2021 lost+found
drwxr-xr-x 2 root root 4096 Nov 3 2020 media
drwxr-xr-x 2 root root 4096 Nov 3 2020 mnt
drwxr-xr-x 2 root root 4096 Nov 3 2020 opt
dr-xr-xr-x 367 root root 0 Jan 31 09:17 proc
dr-xr-x--- 2 root root 4096 Sep 15 2021 root
drwxr-xr-x 11 root root 4096 Sep 15 2021 run
lrwxrwxrwx 1 root root 8 Nov 3 2020 sbin -> usr/sbin
drwxr-xr-x 2 root root 4096 Nov 3 2020 srv
dr-xr-xr-x 13 root root 0 Jan 31 09:17 sys
drwxrwxrwt 7 root root 4096 Sep 15 2021 tmp
drwxr-xr-x 12 root root 4096 Sep 15 2021 usr
drwxr-xr-x 20 root root 4096 Sep 15 2021 var
drwxr-xr-x 2 root root 4096 Jan 31 09:17 volume01
drwxr-xr-x 2 root root 4096 Jan 31 09:17 volume02
```

Loading…
Cancel
Save