从Docker容器获取控制台输出 [英] Getting console output from a Docker container

查看:2406
本文介绍了从Docker容器获取控制台输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用安装的Python和Python应用程序构建映像。我的Python应用程序是一个 Hello,World!应用程序,仅打印 Hello,World!。屏幕上。 Dockerfile:

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"]

在控制台中,我执行:

docker run xxx/zzz

我可以看到您好,世界!输出。现在,我尝试使用ECS中的任务来执行相同的应用程序。我已经将其拉到Docker Hub。

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.

我如何看到输出 Hello,World!

推荐答案

docker日志<容器ID> 将显示容器运行的所有输出。如果您在ECS上运行它,则可能需要为运行容器的主机设置 DOCKER_HOST = tcp:// ip:port

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.

这篇关于从Docker容器获取控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆