=================
== The Archive ==
=================

[Docker ๐Ÿณ] Container ๋กœ๊ทธ ๊ฐ€์ ธ์˜ค๊ธฐ

|

AI Summary

  • AWS EC2์—์„œ Docker ์ปจํ…Œ์ด๋„ˆ ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•  ๋•Œ docker logs ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.
  • docker logs -f --tail 10 {{container-name}} ๋ช…๋ น์–ด๋กœ ์ตœ๊ทผ 10์ค„ ๋กœ๊ทธ๋ฅผ ์‹ค์‹œ๊ฐ„์œผ๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ์ฃผ์š” ์˜ต์…˜์œผ๋กœ๋Š” --follow(-f), --tail(-n), --since, --timestamps(-t), --details ๋“ฑ์ด ์žˆ๋‹ค.
  • --follow ์˜ต์…˜์€ ๋กœ๊ทธ๋ฅผ ์‹ค์‹œ๊ฐ„์œผ๋กœ ๊ณ„์† ์ถœ๋ ฅํ•˜๋ฉฐ, --tail์€ ์ถœ๋ ฅํ•  ๋งˆ์ง€๋ง‰ ์ค„ ์ˆ˜๋ฅผ ์ง€์ •ํ•œ๋‹ค.
  • --since์™€ --until ์˜ต์…˜์œผ๋กœ ํŠน์ • ์‹œ๊ฐ„ ๋ฒ”์œ„ ๋‚ด ๋กœ๊ทธ๋ฅผ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ์ž์„ธํ•œ ์˜ต์…˜๊ณผ ์‚ฌ์šฉ๋ฒ•์€ Docker ๊ณต์‹ ๋ฌธ์„œ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
Updated: 2025-11-22 15:36 UTC

์ตœ๊ทผ AWS EC2 ๋ฅผ ์‚ฌ์ด๋“œ ํ”„๋กœ์ ํŠธ์— ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋ฉด์„œ, ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•  ์ผ์ด ์ƒ๊ฒผ๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ํ„ฐ๋ฏธ๋„์—์„œ ssh ๋กœ EC2 ์— ์ ‘์†ํ•˜๋‹ค๋ณด๋‹ˆ, ๋กœ๊ทธ๋ฅผ tui ๋กœ ๋ด์•ผํ•˜๋Š”๊ฒŒ ์•„๋‹Œ๊ฐ€?

๊ธฐ์กด์— ๋กœ๊ทธ๋ฅผ ํŒŒ์•…ํ•˜๋Š” tail -f ์ฒ˜๋Ÿผ docker cli ์—๋„ ๋น„์Šทํ•œ๊ฒŒ ์žˆ๋Š”์ง€ ์ฐพ์•„๋ดค๊ณ , ์กด์žฌํ–ˆ๋‹ค.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
[ec2-user@server ~]$ docker logs -f --tail 10 {{container-name}}
This generated password is for development use only. Your security configuration must be updated before running your application in production.

2023-09-10T03:22:14.481+09:00  INFO 1 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2023-09-10T03:22:14.601+09:00  INFO 1 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [~~~]
2023-09-10T03:22:16.289+09:00  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2023-09-10T03:22:16.340+09:00  INFO 1 --- [           main] m.z.ServerApplicationKt                  : Started ServerApplicationKt in 14.852 seconds (process running for 16.395)
2023-09-10T03:22:25.913+09:00  INFO 1 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-09-10T03:22:25.917+09:00  INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-09-10T03:22:25.928+09:00  INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 9 ms
2023-09-10T03:23:50.857+09:00  INFO 1 --- [nio-8080-exec-6] o.springdoc.api.AbstractOpenApiResource  : Init duration for springdoc-openapi is: 2049 ms

๋‹ค๋ฅธ ์˜ต์…˜์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

OptionShortDefaultDescription
--detailsfalseShow extra details provided to logs
--follow-ffalseFollow log output
--sinceShow logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)
--tail-nallNumber of lines to show from the end of the logs
--timestamps-tfalseShow timestamps
--untilAPI 1.35+ Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)

References

Categories:

Tags: