Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting console output from a Docker container

I build an image with Python installed and a Python application too. My Python application is a Hello, World! application, just printing "Hello, World!" on the 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 trying to execute the same application, using the task from ECS. I already pulled it to Docker Hub.

How can I see the output Hello, World!? Is there a way to see that my container runs correctly?

like image 213
p.magalhaes Avatar asked Oct 12 '15 14:10

p.magalhaes


People also ask

How can I check the output of a running docker container?

docker logs <container id> will show you all the output of the container 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.

Can code be extracted from docker image?

1. Using COPY or ADD command: You can use COPY or ADD command within Dockerfile to copy your file/code into the Docker container. The following Dockerfile example shows how to add the current working directory files and folders into the directory /usr/Qxf2_POM of the container image.


2 Answers

docker logs <container id> will show you all the output of the container 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.

like image 194
dnephin Avatar answered Oct 02 '22 03:10

dnephin


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.

like image 24
ElasticCode Avatar answered Oct 02 '22 02:10

ElasticCode