跳到主要内容

docker logs 命令

docker logs 命令用于查看容器日志,用法 docker ps 容器 ,示例:

ubuntu@zxzsk.com:~$ docker ps 
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b56d52dd840a nginx "/docker-entrypoint.…" About a minute ago Up 33 seconds 0.0.0.0:32774->80/tcp, :::32774->80/tcp mystifying_meninsky
a6f06d0703ba wcjiang/reference "/busybox httpd -f -…" About a minute ago Up 33 seconds 0.0.0.0:32775->3000/tcp, :::32775->3000/tcp keen_zhukovsky

ubuntu@zxzsk.com:~$ docker logs b56d52dd840a
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2025/02/25 05:02:21 [notice] 1#1: using the "epoll" event method
2025/02/25 05:02:21 [notice] 1#1: nginx/1.27.4
2025/02/25 05:02:21 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2025/02/25 05:02:21 [notice] 1#1: OS: Linux 6.11.0-13-generic
2025/02/25 05:02:21 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1024:524288
2025/02/25 05:02:21 [notice] 1#1: start worker processes
2025/02/25 05:02:21 [notice] 1#1: start worker process 29
2025/02/25 05:02:21 [notice] 1#1: start worker process 30
2025/02/25 05:02:46 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2025/02/25 05:02:46 [notice] 29#29: gracefully shutting down
2025/02/25 05:02:46 [notice] 29#29: exiting
2025/02/25 05:02:46 [notice] 29#29: exit
2025/02/25 05:02:46 [notice] 30#30: gracefully shutting down
2025/02/25 05:02:46 [notice] 30#30: exiting
2025/02/25 05:02:46 [notice] 30#30: exit
2025/02/25 05:02:46 [notice] 1#1: signal 17 (SIGCHLD) received from 29
2025/02/25 05:02:46 [notice] 1#1: worker process 29 exited with code 0
2025/02/25 05:02:46 [notice] 1#1: worker process 30 exited with code 0
2025/02/25 05:02:46 [notice] 1#1: exit
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2025/02/25 05:03:11 [notice] 1#1: using the "epoll" event method
2025/02/25 05:03:11 [notice] 1#1: nginx/1.27.4
2025/02/25 05:03:11 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2025/02/25 05:03:11 [notice] 1#1: OS: Linux 6.11.0-13-generic
2025/02/25 05:03:11 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1024:524288
2025/02/25 05:03:11 [notice] 1#1: start worker processes
2025/02/25 05:03:11 [notice] 1#1: start worker process 21
2025/02/25 05:03:11 [notice] 1#1: start worker process 22