실행시킨 컨테이너가 잘 동작하는지, 에러가 발생한건 아닌지 로그를 확인할 수 있어야 한다. 디버깅시 로그 확인은 필수다.
1. 컨테이너(Container) 로그 조회
1) 특정 컨테이너의 모든 로그 조회
# docker logs 컨테이너 ID / 컨테이너명 : 특정 컨테이너의 모든 로그 조회
- Windows PowerShell
PS C:\Users\admin> docker run nginx
/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
2026/05/03 07:24:24 [notice] 1#1: using the "epoll" event method
2026/05/03 07:24:24 [notice] 1#1: nginx/1.29.8
2026/05/03 07:24:24 [notice] 1#1: built by gcc 14.2.0 (Debian 14.2.0-19)
2026/05/03 07:24:24 [notice] 1#1: OS: Linux 6.6.87.2-microsoft-standard-WSL2
2026/05/03 07:24:24 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2026/05/03 07:24:24 [notice] 1#1: start worker processes
2026/05/03 07:24:24 [notice] 1#1: start worker process 29
2026/05/03 07:24:24 [notice] 1#1: start worker process 30
2026/05/03 07:24:24 [notice] 1#1: start worker process 31
2026/05/03 07:24:24 [notice] 1#1: start worker process 32
2026/05/03 07:24:24 [notice] 1#1: start worker process 33
2026/05/03 07:24:24 [notice] 1#1: start worker process 34
2026/05/03 07:24:24 [notice] 1#1: start worker process 35
2026/05/03 07:24:24 [notice] 1#1: start worker process 36
2026/05/03 07:24:24 [notice] 1#1: start worker process 37
2026/05/03 07:24:24 [notice] 1#1: start worker process 38
2026/05/03 07:24:24 [notice] 1#1: start worker process 39
2026/05/03 07:24:24 [notice] 1#1: start worker process 40
2026/05/03 07:24:24 [notice] 1#1: start worker process 41
2026/05/03 07:24:24 [notice] 1#1: start worker process 42
2026/05/03 07:24:24 [notice] 1#1: start worker process 43
2026/05/03 07:24:24 [notice] 1#1: start worker process 44
2026/05/03 07:24:24 [notice] 1#1: start worker process 45
2026/05/03 07:24:24 [notice] 1#1: start worker process 46
2026/05/03 07:24:24 [notice] 1#1: start worker process 47
2026/05/03 07:24:24 [notice] 1#1: start worker process 48
2026/05/03 07:24:27 [notice] 1#1: signal 2 (SIGINT) received, exiting
2026/05/03 07:24:27 [notice] 29#29: exiting
2026/05/03 07:24:27 [notice] 30#30: exiting
2026/05/03 07:24:27 [notice] 43#43: exiting
2026/05/03 07:24:27 [notice] 29#29: exit
2026/05/03 07:24:27 [notice] 31#31: exiting
2026/05/03 07:24:27 [notice] 43#43: exit
2026/05/03 07:24:27 [notice] 31#31: exit
2026/05/03 07:24:27 [notice] 48#48: exiting
2026/05/03 07:24:27 [notice] 32#32: exiting
2026/05/03 07:24:27 [notice] 32#32: exit
2026/05/03 07:24:27 [notice] 33#33: exiting
2026/05/03 07:24:27 [notice] 33#33: exit
2026/05/03 07:24:27 [notice] 34#34: exiting
2026/05/03 07:24:27 [notice] 34#34: exit
2026/05/03 07:24:27 [notice] 45#45: exiting
2026/05/03 07:24:27 [notice] 47#47: exiting
2026/05/03 07:24:27 [notice] 45#45: exit
2026/05/03 07:24:27 [notice] 47#47: exit
2026/05/03 07:24:27 [notice] 35#35: exiting
2026/05/03 07:24:27 [notice] 35#35: exit
2026/05/03 07:24:27 [notice] 46#46: exiting
2026/05/03 07:24:27 [notice] 36#36: exiting
2026/05/03 07:24:27 [notice] 46#46: exit
2026/05/03 07:24:27 [notice] 37#37: exiting
2026/05/03 07:24:27 [notice] 38#38: exiting
2026/05/03 07:24:27 [notice] 38#38: exit
2026/05/03 07:24:27 [notice] 39#39: exiting
2026/05/03 07:24:27 [notice] 44#44: exiting
2026/05/03 07:24:27 [notice] 36#36: exit
2026/05/03 07:24:27 [notice] 39#39: exit
2026/05/03 07:24:27 [notice] 44#44: exit
2026/05/03 07:24:27 [notice] 40#40: exiting
2026/05/03 07:24:27 [notice] 40#40: exit
2026/05/03 07:24:27 [notice] 41#41: exiting
2026/05/03 07:24:27 [notice] 41#41: exit
2026/05/03 07:24:27 [notice] 42#42: exiting
2026/05/03 07:24:27 [notice] 42#42: exit
2026/05/03 07:24:27 [notice] 48#48: exit
2026/05/03 07:24:27 [notice] 30#30: exit
2026/05/03 07:24:27 [notice] 37#37: exit
2026/05/03 07:24:27 [notice] 1#1: signal 17 (SIGCHLD) received from 41
2026/05/03 07:24:27 [notice] 1#1: worker process 41 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: signal 29 (SIGIO) received
2026/05/03 07:24:27 [notice] 1#1: signal 17 (SIGCHLD) received from 38
2026/05/03 07:24:27 [notice] 1#1: worker process 29 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 38 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 39 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: signal 29 (SIGIO) received
2026/05/03 07:24:27 [notice] 1#1: signal 17 (SIGCHLD) received from 44
2026/05/03 07:24:27 [notice] 1#1: worker process 31 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 40 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 44 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 45 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: signal 29 (SIGIO) received
2026/05/03 07:24:27 [notice] 1#1: signal 17 (SIGCHLD) received from 37
2026/05/03 07:24:27 [notice] 1#1: worker process 34 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 37 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 42 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: signal 29 (SIGIO) received
2026/05/03 07:24:27 [notice] 1#1: signal 17 (SIGCHLD) received from 43
2026/05/03 07:24:27 [notice] 1#1: worker process 30 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 32 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 36 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 43 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: signal 29 (SIGIO) received
2026/05/03 07:24:27 [notice] 1#1: signal 17 (SIGCHLD) received from 30
2026/05/03 07:24:27 [notice] 1#1: signal 17 (SIGCHLD) received from 47
2026/05/03 07:24:27 [notice] 1#1: worker process 47 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: signal 29 (SIGIO) received
2026/05/03 07:24:27 [notice] 1#1: signal 17 (SIGCHLD) received from 48
2026/05/03 07:24:27 [notice] 1#1: worker process 46 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: worker process 48 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: signal 29 (SIGIO) received
2026/05/03 07:24:27 [notice] 1#1: signal 17 (SIGCHLD) received from 46
2026/05/03 07:24:27 [notice] 1#1: worker process 33 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: signal 17 (SIGCHLD) received from 35
2026/05/03 07:24:27 [notice] 1#1: worker process 35 exited with code 0
2026/05/03 07:24:27 [notice] 1#1: exit
포그라운드에서 본 로그를 백그라운드에서도 본다.
- Windows PowerShell
PS C:\Users\admin> docker run -d nginx
0af071c3b0cf783e6894bbeec3f7abdb92809753ac93b8ddbb2fb2265b96f22b
PS C:\Users\admin> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0af071c3b0cf nginx "/docker-entrypoint.…" 10 seconds ago Up 10 seconds 80/tcp interesting_kowalevski
PS C:\Users\admin> docker logs 0af0
/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
2026/05/03 07:25:35 [notice] 1#1: using the "epoll" event method
2026/05/03 07:25:35 [notice] 1#1: nginx/1.29.8
2026/05/03 07:25:35 [notice] 1#1: built by gcc 14.2.0 (Debian 14.2.0-19)
2026/05/03 07:25:35 [notice] 1#1: OS: Linux 6.6.87.2-microsoft-standard-WSL2
2026/05/03 07:25:35 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2026/05/03 07:25:35 [notice] 1#1: start worker processes
2026/05/03 07:25:35 [notice] 1#1: start worker process 29
2026/05/03 07:25:35 [notice] 1#1: start worker process 30
2026/05/03 07:25:35 [notice] 1#1: start worker process 31
2026/05/03 07:25:35 [notice] 1#1: start worker process 32
2026/05/03 07:25:35 [notice] 1#1: start worker process 33
2026/05/03 07:25:35 [notice] 1#1: start worker process 34
2026/05/03 07:25:35 [notice] 1#1: start worker process 35
2026/05/03 07:25:35 [notice] 1#1: start worker process 36
2026/05/03 07:25:35 [notice] 1#1: start worker process 37
2026/05/03 07:25:35 [notice] 1#1: start worker process 38
2026/05/03 07:25:35 [notice] 1#1: start worker process 39
2026/05/03 07:25:35 [notice] 1#1: start worker process 40
2026/05/03 07:25:35 [notice] 1#1: start worker process 41
2026/05/03 07:25:35 [notice] 1#1: start worker process 42
2026/05/03 07:25:35 [notice] 1#1: start worker process 43
2026/05/03 07:25:35 [notice] 1#1: start worker process 44
2026/05/03 07:25:35 [notice] 1#1: start worker process 45
2026/05/03 07:25:35 [notice] 1#1: start worker process 46
2026/05/03 07:25:35 [notice] 1#1: start worker process 47
2026/05/03 07:25:35 [notice] 1#1: start worker process 48
2) 최근 로그 10줄만 조회
# dokcer logs --tail 숫자(로그 끝부터 표시할 줄의 수) 컨테이너 ID / 컨테이너명 : 최근 로그를 입력한 숫자의 줄만 조회
- Windows PowerShell
PS C:\Users\admin> docker logs --tail 10 0af0
2026/05/03 07:25:35 [notice] 1#1: start worker process 39
2026/05/03 07:25:35 [notice] 1#1: start worker process 40
2026/05/03 07:25:35 [notice] 1#1: start worker process 41
2026/05/03 07:25:35 [notice] 1#1: start worker process 42
2026/05/03 07:25:35 [notice] 1#1: start worker process 43
2026/05/03 07:25:35 [notice] 1#1: start worker process 44
2026/05/03 07:25:35 [notice] 1#1: start worker process 45
2026/05/03 07:25:35 [notice] 1#1: start worker process 46
2026/05/03 07:25:35 [notice] 1#1: start worker process 47
2026/05/03 07:25:35 [notice] 1#1: start worker process 48
3) 기존 로그 조회 + 생성되는 로그를 실시간으로 보고 싶은 경우
# docker logs -f 컨테이너 ID / 컨테이너명 : 기존 로그 + 생성되는 로그 실시간 조회
- Windows PowerShell
# Nginx의 컨테이너에 실시간으로 쌓이는 로그 확인하기
PS C:\Users\admin> docker run -d -p 80:80 nginx
178cd31690ca618be924c2414f00584be830b1407c9dc0df84dab0d01a0c4c97
PS C:\Users\admin> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
178cd31690ca nginx "/docker-entrypoint.…" 5 seconds ago Up 4 seconds 0.0.0.0:80->80/tcp, [::]:80->80/tcp wonderful_fermi
0af071c3b0cf nginx "/docker-entrypoint.…" 7 minutes ago Up 7 minutes 80/tcp interesting_kowalevski
PS C:\Users\admin> docker logs -f 178c
/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
2026/05/03 07:32:41 [notice] 1#1: using the "epoll" event method
2026/05/03 07:32:41 [notice] 1#1: nginx/1.29.8
2026/05/03 07:32:41 [notice] 1#1: built by gcc 14.2.0 (Debian 14.2.0-19)
2026/05/03 07:32:41 [notice] 1#1: OS: Linux 6.6.87.2-microsoft-standard-WSL2
2026/05/03 07:32:41 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2026/05/03 07:32:41 [notice] 1#1: start worker processes
2026/05/03 07:32:41 [notice] 1#1: start worker process 29
2026/05/03 07:32:41 [notice] 1#1: start worker process 30
2026/05/03 07:32:41 [notice] 1#1: start worker process 31
2026/05/03 07:32:41 [notice] 1#1: start worker process 32
2026/05/03 07:32:41 [notice] 1#1: start worker process 33
2026/05/03 07:32:41 [notice] 1#1: start worker process 34
2026/05/03 07:32:41 [notice] 1#1: start worker process 35
2026/05/03 07:32:41 [notice] 1#1: start worker process 36
2026/05/03 07:32:41 [notice] 1#1: start worker process 37
2026/05/03 07:32:41 [notice] 1#1: start worker process 38
2026/05/03 07:32:41 [notice] 1#1: start worker process 39
2026/05/03 07:32:41 [notice] 1#1: start worker process 40
2026/05/03 07:32:41 [notice] 1#1: start worker process 41
2026/05/03 07:32:41 [notice] 1#1: start worker process 42
2026/05/03 07:32:41 [notice] 1#1: start worker process 43
2026/05/03 07:32:41 [notice] 1#1: start worker process 44
2026/05/03 07:32:41 [notice] 1#1: start worker process 45
2026/05/03 07:32:41 [notice] 1#1: start worker process 46
2026/05/03 07:32:41 [notice] 1#1: start worker process 47
2026/05/03 07:32:41 [notice] 1#1: start worker process 48
172.17.0.1 - - [03/May/2026:07:35:02 +0000] "GET / HTTP/1.1" 200 896 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" "-"
172.17.0.1 - - [03/May/2026:07:35:02 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" "-"
2026/05/03 07:35:02 [error] 29#29: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/"
172.17.0.1 - - [03/May/2026:07:35:07 +0000] "GET / HTTP/1.1" 200 896 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" "-"
172.17.0.1 - - [03/May/2026:07:35:07 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" "-"
2026/05/03 07:35:07 [error] 29#29: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/"
172.17.0.1 - - [03/May/2026:07:35:08 +0000] "GET / HTTP/1.1" 200 896 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" "-"
172.17.0.1 - - [03/May/2026:07:35:08 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" "-"
2026/05/03 07:35:08 [error] 29#29: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/
브라우저에서 http://localhost:80/ 접속 후 새로고침 할 때마다 실시간으로 로그가 쌓이는게 보인다.
· -f : follow 의 약어
4) 기존 로그는 조회하지 않기 + 생성되는 로그를 실시간으로 보고 싶은 경우
# docker logs --tail 숫자(로그 끝부터 표시할 줄의 수) -f 컨테이너 ID / 컨테이너명 : 기존 로그 숫자만큼 출력 + 생성되는 로그 실시간 조회
- Windows PowerShell
PS C:\Users\admin> docker logs --tail 0 -f 178c
172.17.0.1 - - [03/May/2026:07:41:18 +0000] "GET / HTTP/1.1" 200 896 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" "-"
172.17.0.1 - - [03/May/2026:07:41:19 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" "-"
2026/05/03 07:41:19 [error] 30#30: *2 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/"
172.17.0.1 - - [03/May/2026:07:41:20 +0000] "GET / HTTP/1.1" 200 896 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" "-"
2026/05/03 07:41:20 [error] 30#30: *2 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/"
172.17.0.1 - - [03/May/2026:07:41:20 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36" "-"
브라우저에서 http://localhost:80/ 접속 후 새로고침 할 때마다 실시간으로 로그가 쌓이는게 보인다.
참고링크 : https://www.inflearn.com/course/%EB%B9%84%EC%A0%84%EA%B3%B5%EC%9E%90-docker-%EC%9E%85%EB%AC%B8-%EC%8B%A4%EC%A0%84?cid=334085
비전공자도 이해할 수 있는 Docker 입문/실전| JSCODE 박재성 - 인프런 강의
현재 평점 4.9점 수강생 14,442명인 강의를 만나보세요. 비전공자 입장에서도 쉽게 이해할 수 있고, 실전에서 바로 적용 가능한 Docker 입문/실전 강의를 만들어봤습니다! Docker 기본 개념, Spring Boot를
www.inflearn.com
'강의 실습 > 비전공자도 이해할 수 있는 Docker 입문 실전' 카테고리의 다른 글
| [실습] Docker 전체 흐름 다시 느껴보기 (Nginx 설치 및 실행) (0) | 2026.05.05 |
|---|---|
| 실행중인 컨테이너 내부에 접속하기 (exec -it) (0) | 2026.05.03 |
| 컨테이너(Container) 조회 / 중지 / 삭제 (0) | 2026.05.02 |
| 컨테이너(Container) 생성 / 실행 - 2 (0) | 2026.05.02 |
| 컨테이너(Container) 생성 / 실행 - 1 (0) | 2026.05.01 |
댓글