【问题标题】:Docker run does not display any outputDocker 运行不显示任何输出
【发布时间】:2019-02-13 10:27:16
【问题描述】:

我在树莓派上安装了 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 脚本没有实际输出

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

我也试过以下命令

sudo usermod -aG docker pi
sudo systemctl start docker
sudo docker run hello-world

尝试了以下命令 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

【问题讨论】:

    标签: docker ssh raspberry-pi


    【解决方案1】:

    我在 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.
    

    【讨论】:

    • 知道为什么 'hypriot/armhf-hello-world' 有效而标准的无效吗?
    • 这对我有用
    【解决方案2】:

    我遇到了类似的问题,我的解决方案肯定很幼稚,但我基本上删除了所有容器和图像,然后再试一次。它奏效了。

    # Delete all containers
    docker rm $(docker ps -a -q)
    # Delete all images
    docker rmi $(docker images -q)
    

    【讨论】:

      【解决方案3】:

      我最近在新安装的 Fedora 28(最新)上遇到了同样的问题...容器都以退出代码 139 退出,docker events 说它死了,docker logs 什么也没说。

      我的解决方案是更新 docker(或切换到 CE 版本),因为安装的 docker 版本是 1.13,它已经很旧了。 (fedora教程https://docs.docker.com/install/linux/docker-ce/fedora/

      我还发现了一件可能需要检查的事情...您的容器是否与您的架构兼容(树莓派是 ARM 不是吗?)使用 docker image inspect <image> 搜索 Architecture

      【讨论】:

        【解决方案4】:

        运行:

        docker ps -a
        

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

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

        docker logs <ID>
        

        这将允许您查看日志。

        如果您想在运行时首先看到输出,请在运行命令中添加 -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.
        

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

        docker run -it hello-world > ./test.txt 2>&1
        

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

        【讨论】:

        • 试过`docker run -it hello-world; docker logs 734dd8f733d7`没有输出
        • 没有输出正常运行,也没有日志。使用 '-it' 标志使它工作谢谢。
        猜你喜欢
        • 2023-03-17
        • 1970-01-01
        • 2021-09-04
        • 2021-02-24
        • 1970-01-01
        • 2016-10-26
        • 2016-07-28
        • 1970-01-01
        相关资源
        最近更新 更多