Docker 笔记(三)--容器

Docker 笔记(三)–容器

记录Docker 安装操作记录,便于查询。

参考

  1. 链接: Docker 入门到实战教程(三)镜像和容器
  2. 链接: docker run中的-itd参数正确使用
  3. 链接: docker官方文档
  4. 链接: 阿里云Debian 镜像
  5. 链接: Debian 全球镜像站
  6. 链接: Debian/Ubuntu安装ps,ping,telnet,netstat命令

环境

Centos 7.9

操作

1.启动容器

[root@centos7-18 docker]# docker run -it hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
  • -i: 交互式操作。
  • -t: 终端。
  • hello-world: 镜像名。

2.查看容器

[root@centos7-18 docker]# docker ps -a
CONTAINER ID   IMAGE         COMMAND                   CREATED              STATUS                      PORTS     NAMES
f3cb195bb73d   redis         "docker-entrypoint.s…"   About a minute ago   Exited (0) 47 seconds ago             goofy_cohen
075affeee29d   nginx         "/docker-entrypoint.…"   2 minutes ago        Exited (0) 2 minutes ago              adoring_ride
40da8fbb8f46   hello-world   "/hello"                  7 minutes ago        Exited (0) 7 minutes ago              boring_neumann
[root@centos7-18 docker]# 
  • STATUS 显示容器的运行状态。 注意!停止运行的容器并不会销毁,如果需要容器停止时销毁可以使用–rm 参数.

3.重启容器

[root@centos7-18 docker]# docker restart f3cb195bb73d
f3cb195bb73d
[root@centos7-18 docker]# docker ps
CONTAINER ID   IMAGE     COMMAND                   CREATED          STATUS          PORTS      NAMES
f3cb195bb73d   redis     "docker-entrypoint.s…"   18 minutes ago   Up 10 minutes   6379/tcp   goofy_cohen
[root@centos7-18 docker]# 

4.后台运行

[root@centos7-18 docker]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
nginx         latest    605c77e624dd   22 months ago   141MB
redis         latest    7614ae9453d1   23 months ago   113MB
hello-world   latest    feb5d9fea6a5   2 years ago     13.3kB
[root@centos7-18 docker]# 
[root@centos7-18 docker]# docker run -itd --name nginx-demo nginx:latest
74901d661a79a3116d49f6867d5a8e682feb7c9934482ada35a8bd78f01ff35b
  • -d 后台运行
  • –name 容器别名
  • nginx:latest 镜像名称:TAG
[root@centos7-18 docker]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS          PORTS      NAMES
74901d661a79   nginx:latest   "/docker-entrypoint.…"   16 seconds ago   Up 14 seconds   80/tcp     nginx-demo
f3cb195bb73d   redis          "docker-entrypoint.s…"   30 minutes ago   Up 23 minutes   6379/tcp   goofy_cohen
[root@centos7-18 docker]# 

5.停止运行

// 停止指定的容器
[root@centos7-18 docker]# docker stop f3cb195bb73d
f3cb195bb73d
[root@centos7-18 docker]# docker ps
// 停止所有容器
[root@centos7-18 docker]# docker stop $(docker ps -a -q)
50fc8b373a0a
92176206c4d1
[root@centos7-18 docker]# docker ps

6.进入容器

6.1 进入容器
  • docker exec -it “容器ID”或“容器名称”,可以使用容器ID或容器名称进入容器
[root@centos7-18 docker]# docker ps 
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS          PORTS      NAMES
74901d661a79   nginx:latest   "/docker-entrypoint.…"   24 minutes ago   Up 24 minutes   80/tcp     nginx-demo
f3cb195bb73d   redis          "docker-entrypoint.s…"   55 minutes ago   Up 10 minutes   6379/tcp   goofy_cohen
[root@centos7-18 docker]# docker exec -it f3cb195bb73d /bin/bash
root@f3cb195bb73d:/data# 
[root@centos7-18 docker]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS          PORTS      NAMES
74901d661a79   nginx:latest   "/docker-entrypoint.…"   27 minutes ago   Up 27 minutes   80/tcp     nginx-demo
f3cb195bb73d   redis          "docker-entrypoint.s…"   57 minutes ago   Up 13 minutes   6379/tcp   goofy_cohen
[root@centos7-18 docker]# docker exec -it nginx-demo /bin/bash
root@74901d661a79:/# 
6.2 查看信息
[root@centos7-18 ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS          PORTS     NAMES
19f2fc32fc60   605c77e624dd   "/docker-entrypoint.…"   16 minutes ago   Up 16 minutes   80/tcp    charming_thompson
[root@centos7-18 ~]# docker exec -it 19f2fc32fc60 /bin/bash
root@19f2fc32fc60:/# uname -a
Linux 19f2fc32fc60 3.10.0-1160.6.1.el7.x86_64 #1 SMP Tue Nov 17 13:59:11 UTC 2020 x86_64 GNU/Linux
root@19f2fc32fc60:/# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@19f2fc32fc60:/# 
6.3 换debian源
  • 查看当前源
root@19f2fc32fc60:/etc/apt# cat /etc/apt/sources.list
# deb http://snapshot.debian.org/archive/debian/20211220T000000Z bullseye main
deb http://deb.debian.org/debian bullseye main
# deb http://snapshot.debian.org/archive/debian-security/20211220T000000Z bullseye-security main
deb http://security.debian.org/debian-security bullseye-security main
# deb http://snapshot.debian.org/archive/debian/20211220T000000Z bullseye-updates main
deb http://deb.debian.org/debian bullseye-updates main
root@19f2fc32fc60:/etc/apt# 
  • 备份sources.list
root@19f2fc32fc60:/etc/apt# cp sources.list sources.list.bak
  • 换阿里源
// 清空文件
root@19f2fc32fc60:/etc/apt# echo "">sources.list  
root@19f2fc32fc60:/etc/apt# cat sources.list

// 导入阿里源
root@19f2fc32fc60:/etc/apt# cat > sources.list << EOF
> deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
> deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
> deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
> deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
> deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
> deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
> deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
> deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
> EOF

root@19f2fc32fc60:/etc/apt# echo "
> deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
> deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
>  deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
> deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
> deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
> deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib 
> deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib 
> deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
> " > sources.list 
// 请缓存,更新
root@19f2fc32fc60:/etc/apt# apt-get clean
root@19f2fc32fc60:/etc/apt# apt-get update
Hit:1 https://mirrors.aliyun.com/debian bullseye InRelease
Get:2 https://mirrors.aliyun.com/debian-security bullseye-security InRelease [48.4 kB]
Get:3 https://mirrors.aliyun.com/debian bullseye-updates InRelease [44.1 kB]
Get:4 https://mirrors.aliyun.com/debian bullseye-backports InRelease [49.0 kB]
Get:5 https://mirrors.aliyun.com/debian-security bullseye-security/main Sources [160 kB]
Get:6 https://mirrors.aliyun.com/debian-security bullseye-security/main amd64 Packages [258 kB]
Get:7 https://mirrors.aliyun.com/debian bullseye-updates/main Sources [7428 B]
Get:8 https://mirrors.aliyun.com/debian bullseye-updates/main amd64 Packages [17.7 kB]
Get:9 https://mirrors.aliyun.com/debian bullseye-backports/non-free Sources [4504 B]
Get:10 https://mirrors.aliyun.com/debian bullseye-backports/contrib Sources [4532 B]
Get:11 https://mirrors.aliyun.com/debian bullseye-backports/main Sources [386 kB]
Get:12 https://mirrors.aliyun.com/debian bullseye-backports/non-free amd64 Packages [13.9 kB]
Get:13 https://mirrors.aliyun.com/debian bullseye-backports/main amd64 Packages [404 kB]
Get:14 https://mirrors.aliyun.com/debian bullseye-backports/contrib amd64 Packages [5968 B]
Fetched 1403 kB in 1s (1170 kB/s)
Reading package lists... Done
6.4 安装包
root@19f2fc32fc60:/etc/apt# apt install -y procps vim net-tools inetutils-ping telnet traceroute iproute2   
  • procps 进程管理工具 ps top
  • vim 文本编辑工具
  • net-tools 网络工具 netstat
  • inetutils-ping ping
  • telnet telnet
  • traceroute traceroute
  • iproute2 网络管理工具 ip addr等
6.5 启动服务
  • 启动nginx
root@19f2fc32fc60:/etc/nginx# /etc/init.d/nginx start
2023/11/17 04:16:13 [notice] 606#606: using the "epoll" event method
2023/11/17 04:16:13 [notice] 606#606: nginx/1.21.5
2023/11/17 04:16:13 [notice] 606#606: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2023/11/17 04:16:13 [notice] 606#606: OS: Linux 3.10.0-1160.6.1.el7.x86_64
2023/11/17 04:16:13 [notice] 606#606: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2023/11/17 04:16:13 [notice] 607#607: start worker processes
2023/11/17 04:16:13 [notice] 607#607: start worker process 608
2023/11/17 04:16:13 [notice] 607#607: start worker process 609
  • 查看进程和端口
root@19f2fc32fc60:/etc/nginx# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 04:04 pts/0    00:00:00 /bin/bash
root         7     0  0 04:04 pts/1    00:00:00 bash
root       607     0  0 04:16 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx      608   607  0 04:16 ?        00:00:00 nginx: worker process
nginx      609   607  0 04:16 ?        00:00:00 nginx: worker process
root       610     7  0 04:16 pts/1    00:00:00 ps -ef
root@19f2fc32fc60:/etc/nginx# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      607/nginx: master p 
root@19f2fc32fc60:/etc/nginx# 

7.容器快照

7.1 导出快照
[root@centos7-18 docker]# docker export 74901d661a79 > nginx-demo.tar
[root@centos7-18 docker]# ls
daemon.json  nginx-demo.tar
7.2 导入快照
[root@centos7-18 docker]# docker import nginx-demo.tar nginx-demo:1.0
sha256:c2c8866bef605d74ac27fa1f671803139d09f4b9483f7d2312928036323be955
[root@centos7-18 docker]# docker images nginx-demo:1.0
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
nginx-demo   1.0       c2c8866bef60   3 minutes ago   140MB
[root@centos7-18 docker]# 

注意!导入的快照是镜像。

8.删除容器

8.1 删除停止的容器
  • docker rm “容器ID”
[root@centos7-18 docker]# docker ps -a
CONTAINER ID   IMAGE         COMMAND                   CREATED       STATUS                   PORTS      NAMES
f3cb195bb73d   redis         "docker-entrypoint.s…"   2 hours ago   Up 57 minutes            6379/tcp   goofy_cohen
075affeee29d   nginx         "/docker-entrypoint.…"   2 hours ago   Exited (0) 2 hours ago              adoring_ride
40da8fbb8f46   hello-world   "/hello"                  2 hours ago   Exited (0) 2 hours ago              boring_neumann
[root@centos7-18 docker]# docker rm 40da8fbb8f46
40da8fbb8f46
8.2 强制删除容器
  • docker rm -f “容器ID”
[root@centos7-18 docker]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED             STATUS          PORTS      NAMES
74901d661a79   nginx:latest   "/docker-entrypoint.…"   55 minutes ago      Up 55 minutes   80/tcp     nginx-demo
f3cb195bb73d   redis          "docker-entrypoint.s…"   About an hour ago   Up 41 minutes   6379/tcp   goofy_cohen
[root@centos7-18 docker]# docker rm -f 74901d661a79
74901d661a79
8.3 清除所有停止容器
  • docker container prune
[root@centos7-18 docker]# docker ps -a
CONTAINER ID   IMAGE         COMMAND                   CREATED          STATUS                      PORTS     NAMES
d4d7b7b33e22   hello-world   "/hello"                  31 seconds ago   Exited (0) 31 seconds ago             quizzical_banach
f3cb195bb73d   redis         "docker-entrypoint.s…"   2 hours ago      Exited (0) 4 seconds ago              goofy_cohen
075affeee29d   nginx         "/docker-entrypoint.…"   2 hours ago      Exited (0) 2 hours ago                adoring_ride
[root@centos7-18 docker]# docker container prune 
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
d4d7b7b33e224d0a757ac2a2dd70ff69bf95bfcf584f0c413d774a1382d98355
f3cb195bb73dfb23a0eca591572b97505d57af5afa9880171836285ea5483b3d
075affeee29db528f9c267f3f8ee6263d9aad39f6da9766a91b39a0b2bf5913d

Total reclaimed space: 1.098kB
[root@centos7-18 docker]# docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@centos7-18 docker]# 

9.容器命令

9.1 查询容器内进程
  • docker top “容器ID”
[root@centos7-18 ~]# docker top 19f2fc32fc60
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                21175               21156               0                   13:42               pts/0               00:00:00            /bin/bash
root                21224               21156               0                   13:42               ?                   00:00:00            bash
root                22502               21156               0                   13:53               ?                   00:00:00            nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
101                 22503               22502               0                   13:53               ?                   00:00:00            nginx: worker process
101                 22504               22502               0                   13:53               ?                   00:00:00            nginx: worker process
[root@centos7-18 ~]# 
9.2查询容器信息
  • docker inspect “容器ID”
[root@centos7-18 ~]# docker inspect 19f2fc32fc60
[
   {
    
    
       "Id": "19f2fc32fc604c6b827aa7331df97f059fd85f3792e3d7ac1ffe54e0721ec5bd",
       "Created": "2023-11-15T18:24:24.634633348Z",
       "Path": "/docker-entrypoint.sh",
       "Args": [
           "/bin/bash"
       ],
       "State": {
    
    
           "Status": "running",
           "Running": true,
           "Paused": false,
           "Restarting": false,
           "OOMKilled": false,
           "Dead": false,
           "Pid": 21175,
           "ExitCode": 0,
           "Error": "",
           "StartedAt": "2023-11-17T04:04:20.933228283Z",
           "FinishedAt": "2023-11-17T04:04:09.311054875Z"
       },
       "Image": "sha256:605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85",
       "ResolvConfPath": "/var/lib/docker/containers/19f2fc32fc604c6b827aa7331df97f059fd85f3792e3d7ac1ffe54e0721ec5bd/resolv.conf",
       "HostnamePath": "/var/lib/docker/containers/19f2fc32fc604c6b827aa7331df97f059fd85f3792e3d7ac1ffe54e0721ec5bd/hostname",
       "HostsPath": "/var/lib/docker/containers/19f2fc32fc604c6b827aa7331df97f059fd85f3792e3d7ac1ffe54e0721ec5bd/hosts",
       "LogPath": "/var/lib/docker/containers/19f2fc32fc604c6b827aa7331df97f059fd85f3792e3d7ac1ffe54e0721ec5bd/19f2fc32fc604c6b827aa7331df97f059fd85f3792e3d7ac1ffe54e0721ec5bd-json.log",
       "Name": "/charming_thompson",
       "RestartCount": 0,
       "Driver": "overlay2",
       "Platform": "linux",
       "MountLabel": "",
       "ProcessLabel": "",
       "AppArmorProfile": "",
       "ExecIDs": [
           "d8e103024ca2b38387871139f75a1f9b6f0f59e47a962c17837192c6b71fbeb2"
       ],
       "HostConfig": {
    
    
           "Binds": null,
           "ContainerIDFile": "",
           "LogConfig": {
    
    
               "Type": "json-file",
               "Config": {
    
    }
           },
           "NetworkMode": "default",
           "PortBindings": {
    
    },
           "RestartPolicy": {
    
    
               "Name": "no",
               "MaximumRetryCount": 0
           },
           "AutoRemove": false,
           "VolumeDriver": "",
           "VolumesFrom": null,
           "ConsoleSize": [
               79,
               204
           ],
           "CapAdd": null,
           "CapDrop": null,
           "CgroupnsMode": "host",
           "Dns": [],
           "DnsOptions": [],
           "DnsSearch": [],
           "ExtraHosts": null,
           "GroupAdd": null,
           "IpcMode": "private",
           "Cgroup": "",
           "Links": null,
           "OomScoreAdj": 0,
           "PidMode": "",
           "Privileged": false,
           "PublishAllPorts": false,
           "ReadonlyRootfs": false,
           "SecurityOpt": null,
           "UTSMode": "",
           "UsernsMode": "",
           "ShmSize": 67108864,
           "Runtime": "runc",
           "Isolation": "",
           "CpuShares": 0,
           "Memory": 0,
           "NanoCpus": 0,
           "CgroupParent": "",
           "BlkioWeight": 0,
           "BlkioWeightDevice": [],
           "BlkioDeviceReadBps": [],
           "BlkioDeviceWriteBps": [],
           "BlkioDeviceReadIOps": [],
           "BlkioDeviceWriteIOps": [],
           "CpuPeriod": 0,
           "CpuQuota": 0,
           "CpuRealtimePeriod": 0,
           "CpuRealtimeRuntime": 0,
           "CpusetCpus": "",
           "CpusetMems": "",
           "Devices": [],
           "DeviceCgroupRules": null,
           "DeviceRequests": null,
           "MemoryReservation": 0,
           "MemorySwap": 0,
           "MemorySwappiness": null,
           "OomKillDisable": false,
           "PidsLimit": null,
           "Ulimits": null,
           "CpuCount": 0,
           "CpuPercent": 0,
           "IOMaximumIOps": 0,
           "IOMaximumBandwidth": 0,
           "MaskedPaths": [
               "/proc/asound",
               "/proc/acpi",
               "/proc/kcore",
               "/proc/keys",
               "/proc/latency_stats",
               "/proc/timer_list",
               "/proc/timer_stats",
               "/proc/sched_debug",
               "/proc/scsi",
               "/sys/firmware",
               "/sys/devices/virtual/powercap"
           ],
           "ReadonlyPaths": [
               "/proc/bus",
               "/proc/fs",
               "/proc/irq",
               "/proc/sys",
               "/proc/sysrq-trigger"
           ]
       },
       "GraphDriver": {
    
    
           "Data": {
    
    
               "LowerDir": "/var/lib/docker/overlay2/6f4c29ffd5260d59159a5af2d29812b28cbe65eee2a38dce757709851586261d-init/diff:/var/lib/docker/overlay2/fd8c77083cd9b2c0c9bd36ecf8ade515986d4d9cf536abea70ecb0440fed2907/diff:/var/lib/docker/overlay2/8b0be5030647522bf7b1b39db844d8c650bd8133a00ac05b330879de438c0abb/diff:/var/lib/docker/overlay2/563d515cbd4227114e7adeb014737ce26c3238a9e54135141519c5870470a0e0/diff:/var/lib/docker/overlay2/690c4f6a17cb8cf1aabe042511f57c198281895336138ac474117c60a879cc30/diff:/var/lib/docker/overlay2/3de8af079b18dd20b726da9ce7a91836810e1effd694cc39cccfc63925626d2c/diff:/var/lib/docker/overlay2/b04d78c79c57a4b680bf3f66c56a33b683fd632182f630835ec67d3a400ff965/diff",
               "MergedDir": "/var/lib/docker/overlay2/6f4c29ffd5260d59159a5af2d29812b28cbe65eee2a38dce757709851586261d/merged",
               "UpperDir": "/var/lib/docker/overlay2/6f4c29ffd5260d59159a5af2d29812b28cbe65eee2a38dce757709851586261d/diff",
               "WorkDir": "/var/lib/docker/overlay2/6f4c29ffd5260d59159a5af2d29812b28cbe65eee2a38dce757709851586261d/work"
           },
           "Name": "overlay2"
       },
       "Mounts": [],
       "Config": {
    
    
           "Hostname": "19f2fc32fc60",
           "Domainname": "",
           "User": "",
           "AttachStdin": false,
           "AttachStdout": false,
           "AttachStderr": false,
           "ExposedPorts": {
    
    
               "80/tcp": {
    
    }
           },
           "Tty": true,
           "OpenStdin": true,
           "StdinOnce": false,
           "Env": [
               "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
               "NGINX_VERSION=1.21.5",
               "NJS_VERSION=0.7.1",
               "PKG_RELEASE=1~bullseye"
           ],
           "Cmd": [
               "/bin/bash"
           ],
           "Image": "605c77e624dd",
           "Volumes": null,
           "WorkingDir": "",
           "Entrypoint": [
               "/docker-entrypoint.sh"
           ],
           "OnBuild": null,
           "Labels": {
    
    
               "maintainer": "NGINX Docker Maintainers <[email protected]>"
           },
           "StopSignal": "SIGQUIT"
       },
       "NetworkSettings": {
    
    
           "Bridge": "",
           "SandboxID": "67599d6da2920c16fdd15cfd5f542d3e042db4b126c861e31e9ab52409560be6",
           "HairpinMode": false,
           "LinkLocalIPv6Address": "",
           "LinkLocalIPv6PrefixLen": 0,
           "Ports": {
    
    
               "80/tcp": null
           },
           "SandboxKey": "/var/run/docker/netns/67599d6da292",
           "SecondaryIPAddresses": null,
           "SecondaryIPv6Addresses": null,
           "EndpointID": "6a6b8ab5da195f7ef44743be09f5514c89382d0815f69e8a5f607656875588d6",
           "Gateway": "172.17.0.1",
           "GlobalIPv6Address": "",
           "GlobalIPv6PrefixLen": 0,
           "IPAddress": "172.17.0.2",
           "IPPrefixLen": 16,
           "IPv6Gateway": "",
           "MacAddress": "02:42:ac:11:00:02",
           "Networks": {
    
    
               "bridge": {
    
    
                   "IPAMConfig": null,
                   "Links": null,
                   "Aliases": null,
                   "NetworkID": "2aff696bbb5ba0e6590490d461a8cf35c95f47fee567faa6806a07e680edad0b",
                   "EndpointID": "6a6b8ab5da195f7ef44743be09f5514c89382d0815f69e8a5f607656875588d6",
                   "Gateway": "172.17.0.1",
                   "IPAddress": "172.17.0.2",
                   "IPPrefixLen": 16,
                   "IPv6Gateway": "",
                   "GlobalIPv6Address": "",
                   "GlobalIPv6PrefixLen": 0,
                   "MacAddress": "02:42:ac:11:00:02",
                   "DriverOpts": null
               }
           }
       }
   }
]
9.3查询容器日志
  • docker logs “容器ID”或“容器名称”
[root@centos7-18 ~]# docker  logs  19f2fc32fc60
  // 实时日志
[root@centos7-18 ~]# docker  logs  -f 19f2fc32fc60
  // 从某一时间开始的日志
[root@centos7-18 ~]# docker logs -t --since="2023-11-08T10:00:00"  19f2fc32fc60
  // 30分钟日志
[root@centos7-18 ~]# docker  logs  --since 30m 19f2fc32fc60

猜你喜欢

转载自blog.csdn.net/shijin741231/article/details/134442074
今日推荐