Docker - Ubuntu - bash: ping: command not found Docker - Ubuntu - bash: ping: command not found docker docker

Docker - Ubuntu - bash: ping: command not found


Docker images are pretty minimal, But you can install ping in your official ubuntu docker image via:

apt-get updateapt-get install iputils-ping

Chances are you dont need ping your image, and just want to use it for testing purposes. Above example will help you out.

But if you need ping to exist on your image, you can create a Dockerfile or commit the container you ran the above commands in to a new image.

Commit:

docker commit -m "Installed iputils-ping" --author "Your Name <name@domain.com>" ContainerNameOrId yourrepository/imagename:tag

Dockerfile:

FROM ubuntuRUN apt-get update && apt-get install -y iputils-pingCMD bash

Please note there are best practices on creating docker images, Like clearing apt cache files after and etc.


This is the Docker Hub page for Ubuntu and this is how it is created. It only has (somewhat) bare minimum packages installed, thus if you need anything extra you need to install it yourself.

apt-get update && apt-get install -y iputils-ping

However usually you'd create a "Dockerfile" and build it:

mkdir ubuntu_with_pingcat >ubuntu_with_ping/Dockerfile <<'EOF'FROM ubuntuRUN apt-get update && apt-get install -y iputils-pingCMD bashEOFdocker build -t ubuntu_with_ping ubuntu_with_pingdocker run -it ubuntu_with_ping

Please use Google to find tutorials and browse existing Dockerfiles to see how they usually do things :) For example image size should be minimized by running apt-get clean && rm -rf /var/lib/apt/lists/* after apt-get install commands.


Alternatively you can use a Docker image which already has ping installed, e.g. busybox:

docker run --rm busybox ping SERVER_NAME -c 2