I am following aiodocker example by replacing echo "hello world"
with python -c 'print("hello world")'
, but the logs are not showing.
Below solutions (use PYTHONUNBUFFERED=1
, flush=True
, -u
flag) do not help:
Python app does not print anything when running detached in docker
Why doesn't my docker actually log anything?
import asyncio
import aiodocker
async def run_container():
docker = aiodocker.Docker()
container = await docker.containers.create_or_replace(
config={
'Cmd': ['python', '-c', 'print("hello world")'],
'Image': 'python:3.8.2-buster',
},
name="testing"
)
await container.start()
logs = await container.log(stdout=True, stderr=True)
print(''.join(logs))
await container.delete(force=True)
await docker.close()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(run_container())
loop.close()
What else can be wrong?