0

I am building my first very simple container. The python script simply outputs the message with the number of seconds that have passed.

When I try to read the log using:
docker logs "container name"

I do get the logs, however, it seems like the logs are only sent to the log file at a certain interval. In my case, this interval is about 3.5 minutes. I want there to be a constant stream (so that when the container outputs x, it is immediately written to the log file.

Example of the log with timestamps: (only shows a small part)

...  
2022-08-09T09:46:24.677360000Z Waiting for file... 208 seconds passed  
2022-08-09T09:46:24.677364500Z Waiting for file... 209 seconds passed  
2022-08-09T09:46:24.677369700Z Waiting for file... 210 seconds passed  
2022-08-09T09:46:24.677388700Z Waiting for file... 211 seconds passed  
2022-08-09T09:46:24.677395900Z Waiting for file... 212 seconds passed  
2022-08-09T09:49:54.949131800Z Waiting for file... 213 seconds passed  
2022-08-09T09:49:54.949169300Z Waiting for file... 214 seconds passed  
2022-08-09T09:49:54.949176000Z Waiting for file... 215 seconds passed  
2022-08-09T09:49:54.949180700Z Waiting for file... 216 seconds passed  
...  
  • 1
    what code is writing the logs? can you share it? – rok Aug 09 '22 at 10:35
  • 1
    If it's in Python, [Python app does not print anything when running detached in docker](https://stackoverflow.com/questions/29663459/python-app-does-not-print-anything-when-running-detached-in-docker) discusses this phenomenon. – David Maze Aug 09 '22 at 10:40
  • It is indeed in python, and adding "-u" resolved as posted by David. Is there a way to post Davids comment as an answer to the question? (I am new to stackoverflow) – FeddeHasQuestion Aug 09 '22 at 11:57

1 Answers1

0

use follow flag

--follow, -f    

try it

docker container logs --follow  CONTAINER-NAME

relevant link https://docs.docker.com/engine/reference/commandline/container_logs/#usage

dılo sürücü
  • 3,821
  • 1
  • 26
  • 28