I'm using docker-compose for two containers and I run it using docker-compose up -d
But when I try to see its logs with docker-compose logs -f
it shows me only the logs of one of the containers. I tried running the other container individually and it shows the logs just fine. I appreciate any help.
json-file
(default) or journald
?docker-compose version
command?docker-compose.yml
file?journald
docker-compose version 1.11.2, build dfed245
docker-py version: 2.1.0
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t 3 May 2016
version: '2'
services:
service-whose-logs-are-not-showing:
ports:
- "5553:5554"
image: image-name
command: python3.4 /path/pythonfile.py
volumes:
- /path1:/path2
- /path3:/path4
user: "username"
extra_hosts:
- "mxgateway:172.16.1.1"
restart: always
service-whose-logs-are-showing:
image: image-2-name
command: <command>
restart: always
Note that if I run image-name
by itself, the logs appear just fine.
Thanks.
Hi, I just realized it was an issue with Python not flushing its stdout. I ended up adding the following code to my docker-compose.yml
environment:
- PYTHONUNBUFFERED=1
Do you know if this is a common thing to happen with Docker?
Oh god I spent good time chasing this up :) It happened to me while using Flask, I had to hit save on the python code so the server would restart and flush the accumulated error tracebacks.
Thanks a lot @bibiteix
Most helpful comment
Hi, I just realized it was an issue with Python not flushing its stdout. I ended up adding the following code to my
docker-compose.yml
Do you know if this is a common thing to happen with Docker?