Getting console output from Docker container

2019-06-28 02:56发布

问题:

I build an image with python instaled and a python app to. My python app is a hello world, just printing "Hello World" on screen. Dockerfile:

FROM python:2-onbuild
CMD ["python", "./helloworld.py"]

In the console i execute:

docker run xxx/zzz

i can see the Hello World output. Now i am tryng to execute the same app, using the task from ECS. I already pulled it to Docker Hub. How can I see the output hello world? is the anyway yo see that my container run correctly?

回答1:

docker logs <container id> will show you all the output of the conatiner run. If you're running it on ecs, you'll probably need to set DOCKER_HOST=tcp://ip:port for the host that ran the container.



回答2:

You can log in onto your container instance and do, for example, a docker ps there.

This guide describes how to connect to your container instance:

http://docs.aws.amazon.com/AmazonECS/latest/developerguide/troubleshooting.html#instance-connect



回答3:

We Can Use

docker logs <container name>