Foreword
Docker's three core concepts: Mirror, container, warehouse. Beginners often could not tell the mirror and containers, learned object-oriented classes and instances should know, that with object-oriented concepts which are very similar
we can be seen as mirroring the class, after the container seen as an object of class is instantiated.
docker | Object-Oriented |
---|---|
Mirroring | class |
container | Examples |
View mirror list
Check local use docker images have been downloaded image
- REPOSITORY: represents the repository of the source image
- TAG: mirroring label, distinguish between different versions
- IMAGE ID: image ID, 16 hex composition, unique identification
- CREATED: image creation time
- SIZE: image size
[root@yoyo ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos/python-36-centos7 latest b8d15efaa8ec 2 months ago 651MB
ubuntu 15.10 9b9cb95443b5 2 years ago 137MB
training/webapp latest 6fae60ef3446 4 years ago 349MB
[root@yoyo ~]#
Our local downloaded image file is downloaded from the repository over, each mirror in the warehouse source has a name, that is, REPOSITORY, with a mirror source can have different versions of the same label (TAG) distinguish
Download image
Directly docker pull centos default is the latest version of the latest downloaded
docker pull centos
[root@yoyo ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos
8ba884070f61: Already exists
Digest: sha256:b5e66c4651870a1ad435cd75922fe2cb943c9e973a9673822d1414824a1d0475
Status: Downloaded newer image for centos:latest
[root@yoyo ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos/python-36-centos7 latest b8d15efaa8ec 2 months ago 651MB
centos latest 9f38484d220f 3 months ago 202MB
ubuntu 15.10 9b9cb95443b5 2 years ago 137MB
training/webapp latest 6fae60ef3446 4 years ago 349MB
[root@yoyo ~]#
Search Mirror
docker search search-related image files
[root@yoyo ~]# docker search centos
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 5424 [OK]
ansible/centos7-ansible Ansible on Centos7 121 [OK]
jdeathe/centos-ssh CentOS-6 6.10 x86_64 / CentOS-7 7.6.1810 x86… 110 [OK]
consol/centos-xfce-vnc Centos container with "headless" VNC session… 91 [OK]
imagine10255/centos6-lnmp-php56 centos6-lnmp-php56 57 [OK]
centos/mysql-57-centos7 MySQL 5.7 SQL database server 54
tutum/centos Simple CentOS docker image with SSH access 44
centos/postgresql-96-centos7 PostgreSQL is an advanced Object-Relational … 37
kinogmt/centos-ssh CentOS with SSH 27 [OK]
If I want to download a mirrored version centos7.5, how to find it?
Find TAG version
If you want to find the specified TAG version, open the docker's official website https://hub.docker.com/search/?type=image , search box, enter: centos search.
Click on details, find TAGS, you can see the different versions of the tag
Next, specify the TAG name download, behind the increase in colon: label name
docker pull centos:centos7.5.1804
[root@yoyo ~]# docker pull centos:centos7.5.1804
centos7.5.1804: Pulling from library/centos
5ad559c5ae16: Pull complete
Digest: sha256:7a45e4a1efbaafc1d9aa89925b6fdb33288a96d35ea0581412316e2f0ad3720a
Status: Downloaded newer image for centos:centos7.5.1804
[root@yoyo ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos/python-36-centos7 latest b8d15efaa8ec 2 months ago 651MB
centos centos7.5.1804 cf49811e3cdb 3 months ago 200MB
centos latest 9f38484d220f 3 months ago 202MB
ubuntu 15.10 9b9cb95443b5 2 years ago 137MB
training/webapp latest 6fae60ef3446 4 years ago 349MB
[root@yoyo ~]#
Update image
Download above TAG name is centos7.5.1804, this is too long is not a good record, you can change the one you like TAG name, such as 7.5
Update image must first start the container
docker run -d centos:centos7.5.1804
[root@yoyo ~]# docker run -d centos:centos7.5.1804
64cc20e825e3cb70bdbb5c22dac72b061fba77895e794ae7a06d57d2ddfb8a96
[root@yoyo ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
64cc20e825e3 centos:centos7.5.1804 "/bin/bash" 38 seconds ago Exited (0) 35 seconds ago recursing_ardinghelli
fefdcbb9c662 centos/python-36-centos7 "container-entrypoin…" 24 hours ago Exited (0) 24 hours ago quirky_cray
9df329b5effd centos/python-36-centos7 "container-entrypoin…" 24 hours ago Exited (0) 24 hours ago nifty_roentgen
After starting to see the container id number 64cc20e825e3, according to the container id, to modify
- -m: description of the information submitted
- -a: Specifies the mirroring of
- e218edb10161: Container ID
- runoob / ubuntu: v2: Specifies the name of the target image to be created
docker commit -m="update tag name" -a="yoyo" 64cc20e825e3 centos:7.5
[root@yoyo ~]# docker commit -m="update tag name" -a="yoyo" 64cc20e825e3 centos:7.5
sha256:254d4dfe9df7765ccf511bd8e7ff1f5de96b0b5a0af2542ee4cd30c8ac0575b3
[root@yoyo ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos 7.5 254d4dfe9df7 8 seconds ago 200MB
centos latest b9af5ce31055 35 seconds ago 200MB
centos/python-36-centos7 latest b8d15efaa8ec 2 months ago 651MB
ubuntu 15.10 9b9cb95443b5 2 years ago 137MB
training/webapp latest 6fae60ef3446 4 years ago 349MB
[root@yoyo ~]#
Set up a mirrored TAG
If only the name TAG modified mirror, the mirror can be taken to a new tag Docker with tag names, where id is mirrored id
docker tag 254d4dfe9df7 centos:v7.5
[root@yoyo ~]# docker tag 254d4dfe9df7 centos:v7.5
[root@yoyo ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos 7.5 254d4dfe9df7 9 minutes ago 200MB
centos v7.5 254d4dfe9df7 9 minutes ago 200MB
centos latest b9af5ce31055 9 minutes ago 200MB
centos/python-36-centos7 latest b8d15efaa8ec 2 months ago 651MB
ubuntu 15.10 9b9cb95443b5 2 years ago 137MB
training/webapp latest 6fae60ef3446 4 years ago 349MB
[root@yoyo ~]#
This time will be more than a label v7.5
Remove Mirror
A plurality of TAG 7.5 above, and repeat IMAGE ID may be used docker rmi delete it, you can be added to remove -f argument forces
- -f: Force Delete;
- --no-prune: process without removing the mirror image, the default is removed;
[root@yoyo ~]# docker rmi centos:7.5
Untagged: centos:7.5
[root@yoyo ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos v7.5 254d4dfe9df7 12 minutes ago 200MB
centos latest b9af5ce31055 12 minutes ago 200MB
centos/7.5 latest 62a395cab78e 13 minutes ago 200MB
centos/python-36-centos7 latest b8d15efaa8ec 2 months ago 651MB
centos centos7.5.1804 cf49811e3cdb 3 months ago 200MB
centos <none> 9f38484d220f 3 months ago 202MB
ubuntu 15.10 9b9cb95443b5 2 years ago 137MB
training/webapp latest 6fae60ef3446 4 years ago 349MB
[root@yoyo ~]#
Want to re-do a mirror on the basis of someone else, you need to create a Dockerfile file, say Docker behind how to build our image.