docker镜像管理,仓库管理基本命令

2023-12-13 16:29:35

镜像管理

搜索镜像

语法: docker search 镜像名 [-f stars=100]?

[root@localhost ~]# docker search nginx
NAME                               DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
nginx                              Official build of Nginx.                         19313     [OK]       
unit                               Official build of NGINX Unit: Universal Web …   19        [OK]       
nginxinc/nginx-unprivileged        Unprivileged NGINX Dockerfiles                   136                  
nginx/nginx-ingress                NGINX and  NGINX Plus Ingress Controllers fo…   86                   
nginx/nginx-prometheus-exporter    NGINX Prometheus Exporter for NGINX and NGIN…   33                   
nginxinc/nginx-s3-gateway          Authenticating and caching gateway based on …   3                    
nginx/unit                         This repository is retired, use the Docker o…   64                   
nginx/nginx-ingress-operator       NGINX Ingress Operator for NGINX and NGINX P…   2                    
nginxinc/amplify-agent             NGINX Amplify Agent docker repository            1                    
nginx/nginx-quic-qns               NGINX QUIC interop                               1                    
nginxinc/ingress-demo              Ingress Demo                                     4                    
nginxproxy/nginx-proxy             Automated Nginx reverse proxy for docker con…   119                  
nginxproxy/acme-companion          Automated ACME SSL certificate generation fo…   127                  
bitnami/nginx                      Bitnami nginx Docker Image                       180                  [OK]
bitnami/nginx-ingress-controller   Bitnami Docker Image for NGINX Ingress Contr…   32                   [OK]
ubuntu/nginx                       Nginx, a high-performance reverse proxy & we…   103                  
nginxinc/nginmesh_proxy_debug                                                       0                    
nginxproxy/docker-gen              Generate files from docker container meta-da…   14                   
kasmweb/nginx                      An Nginx image based off nginx:alpine and in…   6                    
nginxinc/mra-fakes3                                                                 0                    
rancher/nginx-ingress-controller                                                    11                   
nginxinc/ngx-rust-tool                                                              0                    
nginxinc/mra_python_base                                                            0                    
nginxinc/nginmesh_proxy_init                                                        0 
[root@localhost ~]# docker search nginx -f stars=100
NAME                          DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
nginx                         Official build of Nginx.                         19313     [OK]       
nginxinc/nginx-unprivileged   Unprivileged NGINX Dockerfiles                   136                  
nginxproxy/nginx-proxy        Automated Nginx reverse proxy for docker con…   119                  
nginxproxy/acme-companion     Automated ACME SSL certificate generation fo…   127                  
bitnami/nginx                 Bitnami nginx Docker Image                       180                  [OK]
ubuntu/nginx                  Nginx, a high-performance reverse proxy & we…   103                  

拉取镜像?

语法:docker pull 镜像名

[root@localhost ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
1f7ce2fa46ab: Pull complete 
9b16c94bb686: Pull complete 
9a59d19f9c5b: Pull complete 
9ea27b074f71: Pull complete 
c6edf33e2524: Pull complete 
84b1ff10387b: Pull complete 
517357831967: Pull complete 
Digest: sha256:10d1f5b58f74683ad34eb29287e07dab1e90f10af243f151bb50aa5dbb4d62ee
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest

查看本地镜像?

grammer:docker images
docker image ls
docker image list
-q 只显示id

方法一
[root@localhost ~]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED         SIZE
nginx                                                      latest    a6bd71f48f68   13 days ago     187MB
mysql                                                      5.7       c20987f18b13   23 months ago   448MB
daocloud.io/library/centos                                 latest    300e315adb2f   2 years ago     209MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   7         300e315adb2f   2 years ago     209MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   latest    300e315adb2f   2 years ago     209MB

方法二
[root@localhost ~]# docker image list
REPOSITORY                                                 TAG       IMAGE ID       CREATED         SIZE
nginx                                                      latest    a6bd71f48f68   13 days ago     187MB
mysql                                                      5.7       c20987f18b13   23 months ago   448MB
daocloud.io/library/centos                                 latest    300e315adb2f   2 years ago     209MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   7         300e315adb2f   2 years ago     209MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   latest    300e315adb2f   2 years ago     209MB

方法三
[root@localhost ~]# docker image ls
REPOSITORY                                                 TAG       IMAGE ID       CREATED         SIZE
nginx                                                      latest    a6bd71f48f68   13 days ago     187MB
mysql                                                      5.7       c20987f18b13   23 months ago   448MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   7         300e315adb2f   2 years ago     209MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   latest    300e315adb2f   2 years ago     209MB
daocloud.io/library/centos                                 latest    300e315adb2f   2 years ago     209MB

查看镜像的详细信息?

语法:docker image inspect 镜像名

[root@localhost ~]# docker image inspect nginx
[
    {
        "Id": "sha256:a6bd71f48f6839d9faae1f29d3babef831e76bc213107682c5cc80f0cbb30866",
        "RepoTags": [
            "nginx:latest"
        ],
        "RepoDigests": [
            "nginx@sha256:10d1f5b58f74683ad34eb29287e07dab1e90f10af243f151bb50aa5dbb4d62ee"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2023-11-21T09:05:32.482668371Z",
        "Container": "a85c8fa20980a9a2650ddfe6d0c466ed963ea55d15a5ebee25a87a98ac6b0206",
        "ContainerConfig": {
            "Hostname": "a85c8fa20980",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.25.3",
                "NJS_VERSION=0.8.2",
                "PKG_RELEASE=1~bookworm"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"nginx\" \"-g\" \"daemon off;\"]"
            ],
            "Image": "sha256:4a4f6f7325711db4e0d3ec9bfccb00ba81cd430304aa0075f6d93fd72347aa63",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
            },
            "StopSignal": "SIGQUIT"
        },
        "DockerVersion": "20.10.23",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.25.3",
                "NJS_VERSION=0.8.2",
                "PKG_RELEASE=1~bookworm"
            ],
            "Cmd": [
                "nginx",
                "-g",
                "daemon off;"
            ],
            "Image": "sha256:4a4f6f7325711db4e0d3ec9bfccb00ba81cd430304aa0075f6d93fd72347aa63",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
            },
            "StopSignal": "SIGQUIT"
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 186779305,
        "VirtualSize": 186779305,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/2f259f271d3d0c461fceb834abab0687cb102e65b2d564988fe9e321f235a172/diff:/var/lib/docker/overlay2/c1aefbac005faed40a54b8e7872f09cccc2e42498149743a841fa9590ac70316/diff:/var/lib/docker/overlay2/1497d9e051ec47717a77433b4da017ff8ea03461c005dd0287318f91f7830da8/diff:/var/lib/docker/overlay2/b99363455c31c9f32185e039e4014f2f6241b56d20932d4ac7e52a7e75250bdc/diff:/var/lib/docker/overlay2/510e7e0c2a8d485049a6cb440ca0ab0026f87b7cebe62c254e268b5d4181ef58/diff:/var/lib/docker/overlay2/767e5e3269be57326f3ad482d7408ef525f8b041fd68c4c9c53e9aa9b31ad11e/diff",
                "MergedDir": "/var/lib/docker/overlay2/8ff5f4fe3deeaf1d5a981724a0065991f9d453aecadd28cd5639b3d7dd739fec/merged",
                "UpperDir": "/var/lib/docker/overlay2/8ff5f4fe3deeaf1d5a981724a0065991f9d453aecadd28cd5639b3d7dd739fec/diff",
                "WorkDir": "/var/lib/docker/overlay2/8ff5f4fe3deeaf1d5a981724a0065991f9d453aecadd28cd5639b3d7dd739fec/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:92770f546e065c4942829b1f0d7d1f02c2eb1e6acf0d1bc08ef0bf6be4972839",
                "sha256:8ae474e0cc8f5a81405b04143604f78bfac4756c523e276a36921a8c4da36567",
                "sha256:f5525891d9e9b43a95b4aa1f79405087922489eb300864a2683262aae0fa5b3a",
                "sha256:66283570f41bca3619443d121a79e810b8a72849b5329319993e538d563b3e2f",
                "sha256:c2d3ab485d1b375fdd309458d69d93f8eb9aba8472e928efa32d9e5eda631440",
                "sha256:cddc309885a283a35ef142af78bc6f2e9c9db10e1981c4ea9cfb2c00b83e68ff",
                "sha256:0d0e9c83b6f775d68c7517aabf39ec9123ffca29672e3c3f83c5af7fc6aa242b"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

?修改镜像名称

语法:docker tag 旧名称 新名称

[root@localhost ~]# docker tag nginx nginx1
[root@localhost ~]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED         SIZE
nginx1                                                     latest    a6bd71f48f68   13 days ago     187MB
nginx                                                      latest    a6bd71f48f68   13 days ago     187MB
mysql                                                      5.7       c20987f18b13   23 months ago   448MB
daocloud.io/library/centos                                 latest    300e315adb2f   2 years ago     209MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   7         300e315adb2f   2 years ago     209MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   latest    300e315adb2f   2 years ago     209MB

删除镜像?

?语法:删除镜像
docker rmi 镜像名
删除所有镜像 -f 强制删除,但是实际镜像不会删除
docker rmi $(docker images -q) [-f]
如果镜像删除不掉,说明可能有容器正在运行

[root@localhost ~]# docker rmi nginx1
Untagged: nginx1:latest
[root@localhost ~]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED         SIZE
nginx                                                      latest    a6bd71f48f68   13 days ago     187MB
mysql                                                      5.7       c20987f18b13   23 months ago   448MB
daocloud.io/library/centos                                 latest    300e315adb2f   2 years ago     209MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   7         300e315adb2f   2 years ago     209MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   latest    300e315adb2f   2 years ago     209MB
[root@localhost ~]# docker run -itd nginx nginx:latest
f45655e36d0007082c69c35e2a846a206f2cb446b1a61660ee453bfd32facb51
[root@localhost ~]# docker rmi nginx
Error response from daemon: conflict: unable to remove repository reference "nginx" (must force) - container aedb201a44cc is using its referenced image a6bd71f48f68
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED         STATUS         PORTS     NAMES
aedb201a44cc   a6bd71f48f68   "/docker-entrypoint.…"   4 minutes ago   Up 4 minutes   80/tcp    focused_wing
[root@localhost ~]# docker rmi nginx -f
Untagged: nginx:latest
Untagged: nginx@sha256:10d1f5b58f74683ad34eb29287e07dab1e90f10af243f151bb50aa5dbb4d62ee
[root@localhost ~]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED         SIZE
<none>                                                     <none>    a6bd71f48f68   13 days ago     187MB
mysql                                                      5.7       c20987f18b13   23 months ago   448MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   7         300e315adb2f   2 years ago     209MB
registry.cn-hangzhou.aliyuncs.com/zhangxiao0520/zxcentos   latest    300e315adb2f   2 years ago     209MB
daocloud.io/library/centos                                 latest    300e315adb2f   2 years ago     209MB

查看镜像的制作过程?

语法:docker history iname

[root@localhost ~]# docker history nginx
IMAGE          CREATED       CREATED BY                                       SIZE      COMMENT
a6bd71f48f68   13 days ago   /bin/sh -c #(nop)  CMD ["nginx" "-g" "daemon…   0B        
<missing>      13 days ago   /bin/sh -c #(nop)  STOPSIGNAL SIGQUIT            0B        
<missing>      13 days ago   /bin/sh -c #(nop)  EXPOSE 80                     0B        
<missing>      13 days ago   /bin/sh -c #(nop)  ENTRYPOINT ["/docker-entr…   0B        
<missing>      13 days ago   /bin/sh -c #(nop) COPY file:9e3b2b63db9f8fc7…   4.62kB    
<missing>      13 days ago   /bin/sh -c #(nop) COPY file:57846632accc8975…   3.02kB    
<missing>      13 days ago   /bin/sh -c #(nop) COPY file:3b1b9915b7dd898a…   298B      
<missing>      13 days ago   /bin/sh -c #(nop) COPY file:caec368f5a54f70a…   2.12kB    
<missing>      13 days ago   /bin/sh -c #(nop) COPY file:01e75c6dd0ce317d…   1.62kB    
<missing>      13 days ago   /bin/sh -c set -x     && groupadd --system -…   112MB     
<missing>      13 days ago   /bin/sh -c #(nop)  ENV PKG_RELEASE=1~bookworm    0B        
<missing>      13 days ago   /bin/sh -c #(nop)  ENV NJS_VERSION=0.8.2         0B        
<missing>      13 days ago   /bin/sh -c #(nop)  ENV NGINX_VERSION=1.25.3      0B        
<missing>      13 days ago   /bin/sh -c #(nop)  LABEL maintainer=NGINX Do…   0B        
<missing>      13 days ago   /bin/sh -c #(nop)  CMD ["bash"]                  0B        
<missing>      13 days ago   /bin/sh -c #(nop) ADD file:d261a6f6921593f1e…   74.8MB   

容器管理?

?创建容器

docker run -itd iname # 运行会启动容器
docker create -it iname # 创建容器,但是不启动
-i 标准的输入输出
-t 分配一个虚拟终端
-d 后台运行
–name 指定容器的名字
-p 指定端口映射
-e 指定环境变量
docker ps 查看运行中容器,-a 可以查看所有状态

[root@localhost ~]# docker run -itd --name mycentos daocloud.io/library/centos:latest
15ca7e76d0ce869120f7b4fa350b215c18ed2e4dcf38f2827b385f8190b03a6d
[root@localhost ~]# docker create -it --name  youcentos daocloud.io/library/centos:latest
5f9f6659aa98f2fa7096e91a459560eeb4ef7c9802de3b6f2acdaeeb93c4ad26
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND       CREATED              STATUS              PORTS     NAMES
15ca7e76d0ce   daocloud.io/library/centos:latest   "/bin/bash"   About a minute ago   Up About a minute             mycentos
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE                               COMMAND                   CREATED              STATUS                         PORTS     NAMES
5f9f6659aa98   daocloud.io/library/centos:latest   "/bin/bash"               17 seconds ago       Created                                  youcentos
15ca7e76d0ce   daocloud.io/library/centos:latest   "/bin/bash"               About a minute ago   Up About a minute                        mycentos

启动,停止容器

docker start cname启动
docker stop cname 停止
docker restart cname 重启
docker pause cname 挂起
docker unpause cname 恢复
docker kill cname 强制关闭
docker rm [-f] cname 删除容器

[root@localhost ~]# docker stop mycentos
mycentos
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@localhost ~]# docker start mycentos
mycentos
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND       CREATED         STATUS         PORTS     NAMES
15ca7e76d0ce   daocloud.io/library/centos:latest   "/bin/bash"   3 minutes ago   Up 8 seconds             mycentos
[root@localhost ~]# docker restart mycentos
mycentos
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND       CREATED         STATUS         PORTS     NAMES
15ca7e76d0ce   daocloud.io/library/centos:latest   "/bin/bash"   3 minutes ago   Up 3 seconds             mycentos
[root@localhost ~]# docker pause mycentos
mycentos
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND       CREATED         STATUS                   PORTS     NAMES
15ca7e76d0ce   daocloud.io/library/centos:latest   "/bin/bash"   4 minutes ago   Up 38 seconds (Paused)             mycentos
[root@localhost ~]# docker unpause mycentos
mycentos
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND       CREATED         STATUS          PORTS     NAMES
15ca7e76d0ce   daocloud.io/library/centos:latest   "/bin/bash"   4 minutes ago   Up 57 seconds             mycentos
[root@localhost ~]# docker rm mycentos
Error response from daemon: You cannot remove a running container 15ca7e76d0ce869120f7b4fa350b215c18ed2e4dcf38f2827b385f8190b03a6d. Stop the container before attempting removal or force remove
[root@localhost ~]# docker rm mycentos -f
mycentos
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

正在运行的容器无法直接删除,要加-f参数?

进入容器

方法一:在创建时不加-d参数,放在前台运行

[root@localhost ~]# docker run -it --name mycentos daocloud.io/library/centos:latest  
[root@97bf29746be5 /]# ls
bin  etc   lib    lost+found  mnt  proc  run   srv  tmp  var
dev  home  lib64  media       opt  root  sbin  sys  usr
[root@97bf29746be5 /]# vi
[root@97bf29746be5 /]# vim
bash: vim: command not found
[root@97bf29746be5 /]# [root@localhost ~]# 
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                               COMMAND       CREATED         STATUS         PORTS     NAMES
97bf29746be5   daocloud.io/library/centos:latest   "/bin/bash"   8 minutes ago   Up 8 minutes             mycentos

使用ctrl+p+q退出,否则退出时会直接关掉容器

方法二、docker attach cname # 通过命令进入容器 COMMAND,不常用

[root@localhost ~]# docker attach mycentos
[root@97bf29746be5 /]# 
[root@97bf29746be5 /]# ls
bin  etc   lib    lost+found  mnt  proc  run   srv  tmp  var
dev  home  lib64  media       opt  root  sbin  sys  usr
[root@97bf29746be5 /]# read escape sequence
[root@localhost ~]# 

方法三、docker exec -it cname command # 进入容器,在退出时无需执行ctrl+p+q,不会影响容器运行

[root@localhost ~]# docker exec -it mycentos /bin/bash
[root@97bf29746be5 /]# ls
bin  etc   lib    lost+found  mnt  proc  run   srv  tmp  var
dev  home  lib64  media       opt  root  sbin  sys  usr
[root@97bf29746be5 /]# 
[root@97bf29746be5 /]# read escape sequence
[root@localhost ~]# ls

查看容器内的进程

docker top cname?

[root@localhost ~]# docker top mycentos
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                9581                9560                0                   02:52               pts/0               00:00:00            /bin/bash
root                9671                9560                0                   03:03               pts/1               00:00:00            /bin/bash

容器使用宿主机资源情况

docker stats [cname]?

[root@localhost ~]# docker stats mycentos
CONTAINER ID   NAME       CPU %     MEM USAGE / LIMIT    MEM %     NET I/O     BLOCK I/O   PIDS
97bf29746be5   mycentos   0.00%     1.051MiB / 7.62GiB   0.01%     656B / 0B   0B / 0B     2
CONTAINER ID   NAME       CPU %     MEM USAGE / LIMIT    MEM %     NET I/O     BLOCK I/O   PIDS
97bf29746be5   mycentos   0.00%     1.051MiB / 7.62GiB   0.01%     656B / 0B   0B / 0B     2
CONTAINER ID   NAME       CPU %     MEM USAGE / LIMIT    MEM %     NET I/O     BLOCK I/O   PIDS
97bf29746be5   mycentos   0.00%     1.051MiB / 7.62GiB   0.01%     656B / 0B   0B / 0B     2

查看容器日志

docker logs cname?

[root@localhost ~]# docker logs mycentos
[root@97bf29746be5 /]# 
[root@97bf29746be5 /]# 
[root@97bf29746be5 /]# 
[root@97bf29746be5 /]# ls
bin  etc   lib    lost+found  mnt  proc  run   srv  tmp  var
dev  home  lib64  media       opt  root  sbin  sys  usr
[root@97bf29746be5 /]# vi
[root@97bf29746be5 /]# vim
bash: vim: command not found
[root@97bf29746be5 /]# 
[root@97bf29746be5 /]# 
[root@97bf29746be5 /]# 
[root@97bf29746be5 /]# 
[root@97bf29746be5 /]# ls
bin  etc   lib    lost+found  mnt  proc  run   srv  tmp 

?等待容器关闭返回值

[root@localhost ~]# docker wait mycentos
0
[root@localhost ~]# docker stop mycentos
mycentos ##在另一个终端上运行

docker 服务日志

[root@localhost ~]# docker events
2023-12-05T06:21:28.923794427+08:00 container kill d8503efb3a0ede2f0dc594c975bf2f6ec395475d8485b4f8170a7e704b505a02 (image=daocloud.io/library/centos:latest, name=dcentos, org.label-schema.build-date=20201204, org.label-schema.license=GPLv2, org.label-schema.name=CentOS Base Image, org.label-schema.schema-version=1.0, org.label-schema.vendor=CentOS, signal=15)
2023-12-05T06:21:29.120902216+08:00 network disconnect 7e1f7288e4d23911d5c149f05642fcb6ba56e90978e6ba8ab0e0bd2278ee4fdc (container=d8503efb3a0ede2f0dc594c975bf2f6ec395475d8485b4f8170a7e704b505a02, name=bridge, type=bridge)
2023-12-05T06:21:29.137326097+08:00 container stop d8503efb3a0ede2f0dc594c975bf2f6ec395475d8485b4f8170a7e704b505a02 (image=daocloud.io/library/centos:latest, name=dcentos, org.label-schema.build-date=20201204, org.label-schema.license=GPLv2, org.label-schema.name=CentOS Base Image, org.label-schema.schema-version=1.0, org.label-schema.vendor=CentOS)
2023-12-05T06:21:29.139900214+08:00 container die d8503efb3a0ede2f0dc594c975bf2f6ec395475d8485b4f8170a7e704b505a02 (execDuration=10021, exitCode=0, image=daocloud.io/library/centos:latest, name=dcentos, org.label-schema.build-date=20201204, org.label-schema.license=GPLv2, org.label-schema.name=CentOS Base Image, org.label-schema.schema-version=1.0, org.label-schema.vendor=CentOS)
[root@localhost ~]# docker stop dcentos
dcentos ## 在一个终端上运行

展示已经映射的端口

docker port cname?

[root@localhost ~]# docker run  -itd --name mynginx2  -p 80:80 nginx:latest
aed26fe26589a52f27d1b23251af68e16426b5e6b013a34f59db17ecf161d3b6
[root@localhost ~]# docker port mynginx2
80/tcp -> 0.0.0.0:80
80/tcp -> [::]:80

查看容器内部的变化

docker diff?

[root@localhost ~]# docker diff mynginx2
C /root
A /root/.bash_history
C /run
A /run/nginx.pid
A /kk
C /var
C /var/cache
C /var/cache/nginx
A /var/cache/nginx/fastcgi_temp
A /var/cache/nginx/proxy_temp
A /var/cache/nginx/scgi_temp
A /var/cache/nginx/uwsgi_temp
A /var/cache/nginx/client_temp
C /etc
C /etc/nginx
C /etc/nginx/conf.d
C /etc/nginx/conf.d/default.conf

文章来源:https://blog.csdn.net/2301_76529529/article/details/134841759
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。