28
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python print の内容が docker logs に見えない件について

Last updated at Posted at 2017-05-04

下記のように Dockerfile があります

CMD ["python", "/app.py"]

app.py にこんな処理があります:

print 'some log'

docker run で起動します:

docker run -d xxx

Logをみます:

docke logs -f yyy

なかなか期待の Log が出てきません。

調べたところ、Python による標準出力のバッファーのが原因だそうです。

バッファーをしなくて直ちに Log を見たい場合、 python -u でアプリを起動すればいいことです。

下記のように修正したら、 docker logs も無事に Log を見ることができました。

CMD ["python", "-u", "/app.py"]
28
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?