Open ruscott2009 opened 2 years ago
might be late. but can you provide what cmd
variable is on your code above
it's working from my side
import docker
client = docker.from_env()
cmd = 'while true; do date && sleep 1s; done'
container = client.containers.run(
image='ubuntu',
detach=True,
command=['/bin/bash', '-c', cmd],
stderr=True,
stdout=True,
)
for line in container.logs(stream=True):
print(line.decode().strip())
I want to stream a running containers stdout logs to my interpreter however the logs don't appear when the container is running. When the container finishes all the logs are printed at once. Any ideas where I can start to troubleshoot this issue? I’m using dockerpy 5.0.3 and Docker Desktop 4.7.1. Thank you in advance.
client = docker.from_env() container = client.containers.run( "ptcloud2ptcloud:latest", command=["/bin/bash", "-c", cmd], volumes=volumes, detach=True, remove=True, stdout=True, stderr=True, cpu_count=7, mem_limit='16g',
)
print("container submitted") for line in container.logs(stream=True): print(line.strip())