简体   繁体   中英

Docker, \“ping\”: executable file not found in $PATH": unknown

I have these two containers on the same network

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": {}
    }
]

When I try to ping the second from the first

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

This is quite strange. How can I check the docker variable $PATH? Which executable file does it refer to? EDIT

Suggested answer asks for echo PATH,but it is the same as from my 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

And

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

I have checked the bin,there is no ping inside

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

The output

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

means that the ping command was not found (either $PATH is misconfigured, or ping is not available, or something else).

How can I check the docker variable $PATH?

Run $ docker exec -ti <CONTAINER> echo $PATH , it should output something like the following

Edit : should be $ docker exec -ti <CONTAINER> bash -c 'echo "$PATH"'

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

$PATH is an environment variable set in *nix shells, it contains the directories where executables are looked up.

Which executable file does it refer to?

As it says in the error output, the ping executable. Once you know the content of $PATH , you can check what the problem is ( ping should be in /bin , at least on the containers I have here atm), and try to solve it.

To open an interactive console to inspect/work on the container, run $ docker exec -ti <CONTAINER> bash .


Update

I have checked the bin,there is no ping inside

You probably have to install iputils-ping , see the answers here , but basically (assuming your container is based on Debian or Ubuntu or similar distribution) run

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

First enter the bash in the container # 1

docker container exec -it CONTAINER bash

In bash, type

apt update

then,

apt install iputils-ping

then,

exit

then type the ping command and it should work fine

eg docker container exec -it new_pizd ping new_nginx2

May be your container is not having ping . login to that container using docker exec -it <Container_Name> bash this will open the bash inside your container. then type below commands. apt-get update;apt-get install iputils-ping;

Instead of using nginx in docker container run command as nginx image doesn't have ping command, use nginx:alpine. nginx:alpine image has ping command associated with it. Example follows

docker container run --name new_nginx2 -d --network my_app_net nginx:alpine

Step -1 docker container exec -it mynginx ping newnginx if above step giving error OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \\"ping\\": executable file not found in $PATH": unknown

Step -2 docker container exec -it mynginx bash

Step-3 apt-get update

Step-4 apt-get install iputils-ping

Step -4 Exit()

Step-5 docker container exec -it mynginx ping newnginx

it will ping .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM