After starting a container with containers.run, the stdout from a C++ App seems to be empty.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Hello everyone,
I am running a docker container based on an ubuntu:bionic based image where I start my C++ testApp with an entrypoint.
Please find below my different codes.
C++ testApp Code Sample:
#include <iostream>
#include <unistd.h>
int main(int argc, char **argv)
{
printf("\nServer is starting... !!\n\n");
while (1)
usleep(100000);
return 1;
}
DockerFile content:
FROM amd64/ubuntu:latest
ADD / test
WORKDIR /test
RUN chmod +x testApp
ENTRYPOINT ["/test/testApp"]
Python Code
import docker, time
imageName = 'test'
imagePath = 'C:/test/image'
dockerClient = docker.from_env()
try:
dockerClient.images.remove(image = imageName, force = True)
except (docker.errors.ImageNotFound):
pass
dockerClient.images.build(path = imagePath, tag = imageName, rm=True)
container = dockerClient.containers.run(imageName, detach=True, name=imageName)
while True:
print(container.logs())
time.sleep(1)
When running my custom container from command line docker run -it test , I have got the logs but when running it with docker-py with dockerClient.containers.run , My logs stays empty.
Does anybody have an idea how to get my logs from my custom container using dockerClient.containers.run ?
It seems to be an issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Python entry points shown in the example: dockerClient.containers.run(..., detach=True) and container.logs(). Compare their behavior with the command-line docker run -it test case and the provided C++ testApp output. Done means the container's startup output can be retrieved consistently through the docker-py call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, docker, python
- Domain
- api, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100