Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

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
like image 992
MikiBelavista Avatar asked Mar 24 '18 10:03

MikiBelavista


2 Answers

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
like image 184
resc Avatar answered Sep 26 '22 04:09

resc


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

e.g. docker container exec -it new_pizd ping new_nginx2

like image 38
Rhonald Avatar answered Sep 22 '22 04:09

Rhonald