docker ,\"ping\": executable file not found in $PATH": unknown

标签 docker

我在同一网络上有这两个容器

docker inspect my_app_net
[
    {
        "Name": "my_app_net",
        "Id": "e136b758e8009e0361168aa0ead14ec85973c8d4f93e65122c22a2ff18f5e61f",
        "Created": "2018-03-22T21:11:51.781623693+01:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "a966584cd491caff18b25fa347b738a0853e5195ac517b5fb26bb019a271fc10": {
                "Name": "new_pizd",
                "EndpointID": "fdbacbbd564aeacccc57367dd082232e0498976ca485597b6ba8f6c82a0d4240",
                "MacAddress": "02:42:ac:13:00:03",
                "IPv4Address": "172.19.0.3/16",
                "IPv6Address": ""
            },
            "b36f350efca1f2e79bef8027a32f992021091fdd701e4d55d98af78984072150": {
                "Name": "new_nginx2",
                "EndpointID": "38731d2618aba0a7c63debd3b30a4c9b530d83a4fddbda97cdd2498298007120",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

当我尝试从第一个开始 ping 第二个时

docker container exec -it new_pizd ping new_nginx2 
OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \"ping\": executable file not found in $PATH": unknown

这很奇怪。 如何检查docker变量$PATH?它引用哪个可执行文件? 编辑

建议的答案要求 echo PATH,但它与我的 Ubuntu shell 中的相同

docker exec -ti new_nginx2 echo $PATH
/home/milenko/eclipse:/home/milenko/miniconda3/bin:/home/milenko/bin:/home/milenko/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

还有

milenko@milenko-System-Product-Name:~$ docker exec -ti new_nginx2 bash
root@b36f350efca1:/# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

我检查了垃圾箱,里面没有 ping

root@b36f350efca1:/bin# ls ping*
ls: cannot access 'ping*': No such file or directory

最佳答案

输出

OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \"ping\": executable file not found in $PATH": unknown

表示ping找不到命令($PATH 配置错误,或 ping 不可用,或其他原因)。

How can I check the docker variable $PATH?

运行 $ docker exec -ti <CONTAINER> echo $PATH ,它应该输出如下内容

编辑:应为 $ docker exec -ti <CONTAINER> bash -c 'echo "$PATH"'

/home/user/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

$PATH是 *nix shell 中设置的环境变量,它包含查找可执行文件的目录。

Which executable file does it refer to?

正如错误输出中所述,ping可执行的。一旦你知道$PATH的内容,您可以检查问题是什么( ping 应该在 /bin 中,至少在我这里 atm 的容器上),并尝试解决它。​​

要打开交互式控制台来检查/操作容器,请运行 $ docker exec -ti <CONTAINER> bash

<小时/>

更新

I have checked the bin,there is no ping inside

您可能必须安装iputils-ping ,查看答案here ,但基本上(假设您的容器基于 Debian 或 Ubuntu 或类似发行版)运行

$ apt-get update
$ apt-get install iputils-ping

关于 docker ,\"ping\": executable file not found in $PATH": unknown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49463719/

相关文章:

docker - 如何使用dockerfile修改nginx访问和错误日​​志位置?

python - 无法在 alpine 3.9 docker 镜像中安装 Dask[complete]

docker - Openshift (Origin) 启用图像以使用 ROOT 用户运行

node.js - Docker代理错误:无法将请求/api/product/B002QYW8LW从本地主机:3000代理到http://本地主机:5000

security - 为什么将 docker daemon 绑定(bind)到 0.0.0.0 容易受到攻击?

php - Docker 和 php-cli

ubuntu - Dokku 安装失败

docker添加 "requires at least one argument"错误

docker - 如何为容器创建用户名和密码,或者如何在容器内设置密码

nginx - Nginx作为Docker容器的反向代理