After installing Docker, start docker
root@slave1:/home/xxx/Documents# service docker start
Stop docker command
root@slave1:/home/xxx/Documents# service docker stop
View running docker version
root@slave1:/home/xxx/Documents# docker --version
Docker version 18.09.7, build 2d0083d
Access to relevant mirrored by pull command
root@slave1:/home/xxx/Documents# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
1ab2bdfe9778: Pull complete
a17e64cfe253: Pull complete
e1288088c7a8: Pull complete
Digest: sha256:53ddb41e46de3d63376579acf46f9a41a8d7de33645db47a486de9769201fec9
Status: Downloaded newer image for nginx:latest
After obtaining the image, by docker run
making it up and running
root@slave1:/home/xxx/Documents# docker run -d -p 8800:80 --name nginx_zhao nginx
780f3120141d2e4c861f3ab190f67d233130b87645db5e93eeef6ada108162fa
root@slave1:/home/xxx/Documents# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
780f3120141d nginx "nginx -g 'daemon of…" 14 seconds ago Up 12 seconds 0.0.0.0:8800->80/tcp nginx_zhao
sudo docker ps -a lists all containers, without -a lists only the running
sudo docker run -d -p 8800:80 --name nginx_zhao nginx
Representation runs the specified image
dudo docker run -d --privileged=true -p 83:80 --name nginx83 nginx
representation elevated privileges
Host Host port: internal container port
-d background
-p 8800: 80 is exposed outside designated internal port container with 8800 proxy 80 corresponds to an external host, like the host
--name specify the mirror last name on behalf of nginx container to run there tag plus the tag name, such as nginx: xxx is the latest default
under +8800 port appears, and then visit the host host address map has already been shown that nginx
pull the mirror there are many places to be modified, such as configuration files, use the exec
command to enter the interior of the container is operated
root@slave1:/home/xxx/Documents# docker exec -it 780f3120141d /bin/bash
root@780f3120141d:/# pwd
/
root@780f3120141d:/# ls -l
total 64
drwxr-xr-x 2 root root 4096 Aug 12 00:00 bin
drwxr-xr-x 2 root root 4096 May 13 20:25 boot
drwxr-xr-x 5 root root 340 Sep 11 01:38 dev
drwxr-xr-x 1 root root 4096 Sep 11 01:38 etc
drwxr-xr-x 2 root root 4096 May 13 20:25 home
drwxr-xr-x 1 root root 4096 Aug 15 21:22 lib
drwxr-xr-x 2 root root 4096 Aug 12 00:00 lib64
drwxr-xr-x 2 root root 4096 Aug 12 00:00 media
drwxr-xr-x 2 root root 4096 Aug 12 00:00 mnt
drwxr-xr-x 2 root root 4096 Aug 12 00:00 opt
dr-xr-xr-x 290 root root 0 Sep 11 01:38 proc
drwx------ 2 root root 4096 Aug 12 00:00 root
drwxr-xr-x 1 root root 4096 Sep 11 01:38 run
drwxr-xr-x 2 root root 4096 Aug 12 00:00 sbin
drwxr-xr-x 2 root root 4096 Aug 12 00:00 srv
dr-xr-xr-x 13 root root 0 Sep 11 01:38 sys
drwxrwxrwt 1 root root 4096 Aug 15 21:22 tmp
drwxr-xr-x 1 root root 4096 Aug 12 00:00 usr
drwxr-xr-x 1 root root 4096 Aug 12 00:00 var
root@780f3120141d:/# nginx -v
nginx version: nginx/1.17.3
root@780f3120141d:/# exit
exit
By inspect
By mirroring obtain detailed information, grep
item retrieval needs
root@slave1:/home/xxx/Documents# docker inspect nginx_zhao |grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",
After entering the interior of the container and change, how to generate a new image for the next direct use
root@slave1:/home/xxx/Documents# docker commit nginx_zhao zhao/nginx:v1.0
sha256:75fe4514801e00e544741efa375fe4eb764186f7a9a75d76c27ee488070c84ae
root@slave1:/home/xxx/Documents# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zhao/nginx v1.0 75fe4514801e 27 seconds ago 126MB
docker commit nginx_zhao zhao/nginx:v1.0
Which nginx_zhao
represents just modified container name or id, zhao/nginx:v1.0
represents the saved image name: back to tag
just commit
the mirror image is stored locally, if you want to submit to the network for reference by other people pull to use it?
You can register an account on https://cloud.docker.com/, submitted to the local mirror https://cloud.docker.com/ up.
Reference: Docker technology introduction and practical Docker basic commands to use and publish mirror