first, get the mirror
1. Command acquired (Docker pull)
--->docker pull [options] [Docker registry address]< warehouse name >:< label >
The specific options can be viewed by command Docker pull--help
For example
--->docker pull hyperledger-fabric:latest
2. Operation, taking Hyperledger-fabric:latest as an example
--->docker run-it--rm hyperledger-fabric:latest Bash
Here the-it is two parameters, I interactive operation-T on behalf of the terminal,--RM container exit is deleted; bash is a shell-style interactive operation I'd like to have
second, listing mirrors
1. The list contains the warehouse name, label, Mirror ID, creation time, and space occupied
-->docker Images
REPOSITORY TAG IMAGE ID CREATED SIZE
HYPERLEDGER/FABRIC-MEMBERSRVC latest b3654d32e4f9 weeks ago 1.417 GB
Hyperledger/fabric-peer latest 21cb00fb27f4 weeks ago 1.424 GB
2. Suspension Mirror
<none> <none> 00285df0df87 Age 342MB
In general, suspension mirrors are worthless and can be removed by command Docker RMI $ (Docker images-q-F Dangling=true)
3. Middle-tier mirroring
Use the command Docker images-a to view
4. List partial Mirrors
root@node1:~# Docker Images Hyperledger/fabric-peer
REPOSITORY TAG IMAGE ID CREATED SIZE
Hyperledger/fabric-peer latest 21cb00fb27f4 weeks ago 1.424 GB
=======================================================================
root@node1:~# Docker Images Hyperledger/fabric-peer:latest
REPOSITORY TAG IMAGE ID CREATED SIZE
Hyperledger/fabric-peer latest 21cb00fb27f4 weeks ago 1.424 GB
=======================================================================
root@node4:~# Docker Images-f Since=hyperledger/fabric-peer:latest
REPOSITORY TAG IMAGE ID CREATED SIZE
Registry latest C9bd19d022f6 9 weeks ago 33.3 MB
HYPERLEDGER/FABRIC-MEMBERSRVC latest b3654d32e4f9 weeks ago 1.417 GB
========================================================================
root@node4:~# Docker Images-f label=com.example.version=0.1
REPOSITORY TAG IMAGE ID CREATED SIZE
5. Display in a specific format
========================================================================
root@node4:~# Docker Images-q
C9bd19d022f6
B3654d32e4f9
21cb00fb27f4
========================================================================
The following command lists only the mirror results that are listed directly, and contains only the mirror ID and warehouse name
===============================================================
root@node4:~# Docker Images--format ' {{. ID}}}: {{. Repository}} "
C9bd19d022f6:registry
B3654d32e4f9:hyperledger/fabric-membersrvc
21cb00fb27f4:hyperledger/fabric-peer
===============================================================
You intend to display it as a table equidistant, with a header row, as the default, but define your own column
==============================================================
root@node4:~# Docker Images--format "table {. id}}\t{{. repository}}\t{{. TAG}} "
IMAGE ID REPOSITORY TAG
C9BD19D022F6 Registry Latest
B3654D32E4F9 HYPERLEDGER/FABRIC-MEMBERSRVC Latest
21cb00fb27f4 Hyperledger/fabric-peer Latest
third, build the mirror
Here's an example of how a Web image is built
1. From the Docker first pull Nginx mirror down
2. Execute Start command
Docker run--name websvr-d-P 80:80 nginx
28a3069293d0b97cdc334fa086884c2af0f04bd5c9ced162cfa3c45b08e94e41
3. This assumes that you already have some experience in website development, open browser access, the following results appear
Now we're starting to revamp the container.
4. Use the following command to enter the container
==============================================================
root@node4:~# Docker exec-it Websvr Bash
root@28a3069293d0:/#
================================================================
root@node4:~# Docker exec-it Websvr Bash
root@28a3069293d0:/# echo ' root@28a3069293d0:/# ls
Bin Boot Dev etc home lib lib64 media mnt opt proc root run sbin SRV sys tmp usr var
root@28a3069293d0:/# exit
Exit
root@node4:~#
================================================================================
4. The following results appear in the Refresh browser
5. See specific changes by Docker diff command
=============================================================
root@node4:~# Docker diff Websvr
C/root
A/root/.bash_history
C/run
A/run/nginx.pid
C/usr
C/usr/share
C/usr/share/nginx
C/usr/share/nginx/html
C/usr/share/nginx/html/index.html
C/var
C/var/cache
C/var/cache/nginx
A/var/cache/nginx/client_temp
A/var/cache/nginx/fastcgi_temp
A/var/cache/nginx/proxy_temp
A/var/cache/nginx/scgi_temp
A/var/cache/nginx/uwsgi_temp
=======================================================================
5. Save modified mirrors through the Docker commit command
The syntax format for Docker commit is
Docker commit [options] < container ID or container name > [warehouse name [: Label]]
==================================================================================
Docker commit--author "Jiangge <guosj@gmail.com>"--message "Modify Web page" Websvr nginx:v2
sha256:b1a172a26b4cee6515d497c76bf9c16f45a188260cccc23c51b2286b5a260007
==================================================================================
6. View a new custom image
root@node4:~# Docker Images Nginx
REPOSITORY TAG IMAGE ID CREATED SIZE
Nginx v2 b1a172a26b4c about a minute ago 181.6 MB-------> This is a new custom image
Nginx latest 19146D5729DC 6 days ago 181.6 MB
===================================================================================
7. View specific historical records
====================================================================================
root@node4:~# Docker History Nginx:v2
IMAGE CREATED CREATED by SIZE COMMENT
b1a172a26b4c 2 minutes ago nginx-g daemon off; The default page is modified by B
19146D5729DC 6 Days Ago/bin/sh-c # (NOP) CMD ["Nginx" "G" "Daemon 0 B
<missing> 6 Days Ago/bin/sh-c # (NOP) expose 443/tcp 80/tcp 0 B
<missing> 6 days ago/bin/sh-c LN-SF/DEV/STDOUT/VAR/LOG/NGINX/22 B
<missing> 6 days ago/bin/sh-c apt-key adv--keyserver hkp://pgp. 58.56 MB
<missing> 6 Days Ago/bin/sh-c # (NOP) ENV nginx_version=1.11.7-1 0 B
<missing> Days Ago/bin/sh-c # (NOP) maintainer NGINX Docker Ma 0 B
<missing> Days Ago/bin/sh-c # (NOP) CMD ["/bin/bash"] 0 B
<missing> Days Ago/bin/sh-c # (NOP) ADD file:1d214d2782eaccc743 123.1 MB
root@node4:~#
=======================================================================================
8. Start Nginx:v2 and map to 81 port
======================================================================================
Docker run--name web2-d-P 81:80 nginx:v2
6209246fae53f53b514a8765dba2e73256a79be8d0b2f35abc48f255df728f09
====================================================================================
9. Browser View
Attention
try not to use Docker commit to customize the mirror, the custom behavior should use Dockerfile to complete. Using the Docker commit command can be a straightforward way to help understand the concept of mirrored tiered storage, but it is not used in the actual environment. First of all, if you look closely at the results of the previous Docker diff webserver, you will find that in addition to the/usr/share/nginx/html/index.html files you really want to modify, there are many files that have been altered or added because of the execution of the command. This is just the simplest operation, if you are installing a package, compiling a build, there will be a large number of irrelevant content is added, if the careless cleanup, will cause the mirror is extremely bloated. In addition, using a Docker commit means that all operations on mirroring are black-box operations, and the resulting mirrors are called black-box mirrors, in other words, other than the person who makes the mirror knows what commands have been executed and how the mirrors were generated. And, except for the current layer, each previous layer will not change, in other words, the result of any modification is only marked, added, modified at the current level, without altering the previous layer. If you use Docker commit to make a mirror, and later modified, each change will make the mirror more bloated once, the deleted layer of things will not be lost, will always follow this mirror, even if not access to the ™. This will make the image more bloated.