In python with docker-py, I am running two docker containers:
- eclipse-mosquitto
- an ubuntu:bionic based image where my C++ App is launched with ENTRYPOINT ["/directory/myApp"]
I use the following docker-py API:
container = client.containers.run(imageName, detach=True, name=containerName, ports = ports, volumes = volumes)
- When it is the eclipse-mosquitto container, if I call container.logs() I got the following logs:
1606303570: mosquitto version 1.6.12 starting
1606303570: Config loaded from /mosquitto/config/mosquitto.conf.
1606303570: Opening ipv4 listen socket on port 1883.
1606303570: Opening ipv6 listen socket on port 1883.
1606303570: mosquitto version 1.6.12 running
- When it is my custom container, if I call container.logs() I got nothing and furthermore logs from Docker Desktop Dashboard is empty too:
This seems to be kind of similar to this issue https://github.com/docker/docker-py/issues/2697
After several tests this is my findings:
- If I run my custom container from command line, logs from Docker Desktop Dashboard are there
- If I run my custom container from '''subprocess.call(docker_cmd)''', logs from Docker Desktop Dashboard are there
- If I run my custom container from '''client.containers.run''', logs from Docker Desktop Dashboard are empty
The same tests with eclipse-mosquitto gives me always a Docker Desktop Dashboard full of logs.
Does anybody have an idea how to get my logs from my custom container using client.containers.run ?
After several days of research, I am able to provide additional information isolating the issue.
C++ testApp Code Sample:
DockerFile content:
Python Code
To summarize, when running my custom container from command line
docker run -it test
, I have got the logs but when running it with docker-py withdockerClient.containers.run
, My logs stays empty.Does anybody have an idea how to get my logs from my custom container using
dockerClient.containers.run
?