问题
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>
回答4:
To view the logs of a Docker container in real time, use the following command:
docker logs -f <CONTAINER>
The -f
or --follow
option will show live log output, Also if the container is stopped it will fetch its logs.
来源:https://stackoverflow.com/questions/33083385/getting-console-output-from-docker-container