Unable to see container logs from my C++ App when using client.containers.run of docker-py

In python with docker-py, I am running two docker containers:

  1. eclipse-mosquitto
  2. 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)
  1. 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
  1. 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:

  1. If I run my custom container from command line, logs from Docker Desktop Dashboard are there
  2. If I run my custom container from ”’subprocess.call(docker_cmd)”’, logs from Docker Desktop Dashboard are there
  3. 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 ?

Source: Docker Questions