Environmental
docker-ce-19.03.1-3.el7.x86_64
CentOS 7
First, use an existing container to create a mirror the commit -docker
1, see the presence of a local mirror
[root@node105 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 5a3221f0137b 9 days ago 126MB hello-world latest fce289e99eb9 7 months ago 1.84kB training/webapp latest 6fae60ef3446 4 years ago 349MB
Check local container running
[root@node105 ~]# docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 15ff843a3404 training/webapp "python app.py" 21 minutes ago Up 21 minutes 0.0.0.0:32768->5000/tcp stoic_moore db8b3e2f1c64 nginx "nginx -g 'daemon of…" About an hour ago Up 36 minutes 0.0.0.0:8081->80/tcp nginx-test [root@node105 ~]#
Check the operation of all vessels
[root@node105 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cdb6408b8370 training/webapp "/bin/bash" 20 minutes ago Exited (0) 15 minutes ago funny_ramanujan 15ff843a3404 training/webapp "python app.py" 22 minutes ago Up 22 minutes 0.0.0.0:32768->5000/tcp stoic_moore db8b3e2f1c64 nginx "nginx -g 'daemon of…" About an hour ago Up 37 minutes 0.0.0.0:8081->80/tcp nginx-test [root@node105 ~]#
2, into the vessel and interactively modify
[root@node105 ~]# docker run -ti training/webapp /bin/bash root@cdb6408b8370:/opt/webapp# ls Procfile app.py requirements.txt tests.py root@cdb6408b8370:/opt/webapp# touch app1.py root@cdb6408b8370:/opt/webapp# ls Procfile app.py app1.py requirements.txt tests.py root@cdb6408b8370:/opt/webapp# exit exit [root@node105 ~]#
3, submit modified to generate a new image
[root@node105 ~]# docker commit -m "Added app1.py" -a "cac2020" 15ff843a3404 training/webapp:v2 sha256:71b135d88d62ba40637c839c2cd955c10c23e187d48e6902f8b8095cf379f251 [root@node105 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE training/webapp v2 71b135d88d62 7 seconds ago 349MB nginx latest 5a3221f0137b 9 days ago 126MB hello-world latest fce289e99eb9 7 months ago 1.84kB training/webapp latest 6fae60ef3446 4 years ago 349MB
-m to specify descriptive information submitted, using our version control tools with the same; -a user can specify the updated information; then is used to create a mirror container ID; and finally specify the name of the target warehouse mirror and tag information. ID information will return after this image was created successfully
4, remove the mirror -dcoker rmi
[root@node105 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE training/webapp v2 71b135d88d62 8 minutes ago 349MB nginx latest 5a3221f0137b 9 days ago 126MB hello-world latest fce289e99eb9 7 months ago 1.84kB training/webapp latest 6fae60ef3446 4 years ago 349MB [root@node105 ~]# docker rmi 71b135d88d62 Untagged: training/webapp:v2 Deleted: sha256:71b135d88d62ba40637c839c2cd955c10c23e187d48e6902f8b8095cf379f251 [root@node105 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 5a3221f0137b 9 days ago 126MB hello-world latest fce289e99eb9 7 months ago 1.84kB training/webapp latest 6fae60ef3446 4 years ago 349MB
Second, the use Dockerfile create a mirror -docker build
1, Dockerfile Syntax:
(1) # is a comment character
(2) FROM specify a dependency mirror, a mirror layer is no more than 127
(3)
Third, the local file system introduced construct mirror -docker import
from the local file system to import an image can be created using a template openvz (container virtualization pioneer technology): Download openvz template for templates.
1, first download the image of a ubuntu-14.04, after using the following command to import:
sudo CAT ubuntu-14.04-x86_64-minimal.tar.gz | Docker Import - Ubuntu: 14.04
2, and then view the newly imported image
Docker Images
the REPOSITORY the TAG ID CREATED the VIRTUAL the IMAGE SIZE
Ubuntu 14.04 05ac7c0b9383 215.5 MB. 17 seconds The ago Member
Fourth, upload image -docker push
to create a mirror image uploaded to the repository to share. Docker Hubhuo or build their own warehouses.
docker push mirror name
Fifth, save and load image
1, save the image as a file
docker save -o want to save the file name you want to save the image
EG:
docker save -o java8.tar lwieske / the Java-8
2, the image file loaded
docker load --input file
or
docker load <filename
EG:
docker load <java8.tar
reference:
Dockerfile grammar Introduction
Creating two ways docker mirror
Docker create a mirror, modify, upload image