gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 04:54:06 26 4
gpt4 key购买 nike

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

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com