Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose not showing logs for all containers #4837

Closed
bibiteix opened this issue May 17, 2017 · 8 comments
Closed

docker-compose not showing logs for all containers #4837

bibiteix opened this issue May 17, 2017 · 8 comments

Comments

@bibiteix
Copy link

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.

@shin-
Copy link

shin- commented May 17, 2017

  • Are you using a different log driver from json-file (default) or journald?
  • What is the output of the docker-compose version command?
  • Can you share your docker-compose.yml file?

@bibiteix
Copy link
Author

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
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.

@bibiteix
Copy link
Author

bibiteix commented May 19, 2017

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?

@eulersson
Copy link

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

@shin- shin- closed this as completed May 3, 2018
@MCTRACO
Copy link

MCTRACO commented Apr 6, 2021

this issue was also happening to me with python.

@brean
Copy link

brean commented Feb 5, 2022

I figured out that for some error output in Python (in my case Tracebacks and "rospy.logerr") are not printed when you set tty: true. So in combination with setting "PYTHONUNBUFFERED=1" I also make sure to not use tty-mode.

@Dav3whit3
Copy link

@brean Thank you very much my man...I can stop headbutting my keyboard now. :3

@arshadnzr
Copy link

environment:
- PYTHONUNBUFFERED=1

Man , i knew it was an stdout issue. cause there was an error and i got the error.

Explanation on what happend
Linux outputs two types of log , which is stdout and stderr . for some reason docker is only printing stdout when run with compose . I guess its a good thing . Compose is used for multiple container managing stuff . and we dont want all the logs to clog up .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants