Docker运行不显示任何输出

sha*_*thi 12 ssh raspberry-pi docker

我在raspberry-pi上安装了docker(通过ssh连接)安装成功。

但是运行docker run hello-world不会产生任何输出。

请注意,我第一次收到有关安装映像的其他消息

Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world ad0f38092cf2: Pull complete Digest: sha256:e366bc07db5e8a50dbabadd94c2a95d212bc103e3557e47df8a2eebd8bb46309 Status: Downloaded newer image for hello-world:latest

但是hello world脚本没有实际输出

注意我使用命令安装了docker curl -sSL https://get.docker.com | sh

我也尝试了以下命令

sudo usermod -aG docker pi
sudo systemctl start docker
sudo docker run hello-world
Run Code Online (Sandbox Code Playgroud)

尝试了以下命令docker ps -a

CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                           PORTS               NAMES
734dd8f733d7        hello-world         "/hello"            About a minute ago   Exited (139) 59 seconds ago                          thirsty_bhaskara
Run Code Online (Sandbox Code Playgroud)

era*_*iri 11

跑:

docker ps -a
Run Code Online (Sandbox Code Playgroud)

并检查您是否可以看到退出的容器。

从输出中获取容器 ID 并键入

docker logs <ID>
Run Code Online (Sandbox Code Playgroud)

这将允许您查看日志。

如果您想在运行时首先看到输出,请-it在运行命令中添加标志

编辑:

我在我的机器上试过:

docker run -it hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete 
Digest: sha256:e366bc07db5e8a50dbabadd94c2a95d212bc103e3557e47df8a2eebd8bb46309
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
Run Code Online (Sandbox Code Playgroud)

也许您的输出被重定向到其他一些流。尝试使用:

docker run -it hello-world > ./test.txt 2>&1
Run Code Online (Sandbox Code Playgroud)

之后检查文件是否有任何内容

  • 正常运行时没有输出,也没有日志。使用“-it”标志使其工作,谢谢。 (3认同)

fug*_*ede 11

我在Raspberry Pi 1B +(armv6l)上遇到了相同的问题。受到@JanDrábek的回答的启发,第一个观察结果是该hello-world图像确实是一个支持ARM 的图像,但是只有在使用hypriot/armhf-hello-world代替之后,我才得到预期的输出:

$ uname -a
Linux 4.1.19+ #858 Tue Mar 15 15:52:03 GMT 2016 armv6l GNU/Linux
$ docker run hello-world  # No output
$ docker image inspect hello-world | grep Architecture  # Arch looks right though
        "Architecture": "arm",
$ docker run hypriot/armhf-hello-world  # This does the job
Hello from Docker.
This message shows that your installation appears to be working correctly.
Run Code Online (Sandbox Code Playgroud)


Mih*_*nde 7

我遇到了类似的问题,我的解决方案绝对非常幼稚,但我基本上删除了所有容器和图像,然后重试。有效。

# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
Run Code Online (Sandbox Code Playgroud)