DEV Community

Devtonight
Devtonight

Posted on • Originally published at devtonight.com

How To Fix "bash: ping: command not found" In Ubuntu Docker Containers

Even though it happens rarely, sometimes, still we need to use the ping command in our Docker containers. The problem with the Ubuntu Docker image is, it is not exactly similar to the regular Ubuntu desktop or server releases that we use in our PCs and servers. That means the official Ubuntu Docker image comes with bare minimum packages installed. So, unfortunately, famous tools like ping and ifconfig (learn how to install) commands will not be there right after we created a container using the official Ubuntu image. But we can easily install the ping command with the following commands.

First, we need to update the local repository of our Docker Ubuntu container.

apt-get update
Enter fullscreen mode Exit fullscreen mode

Then install the ping command. It comes with the iputils-ping package.

apt-get install iputils-ping
Enter fullscreen mode Exit fullscreen mode

After that, you will be able to use the ping command as you normally used it.

ping 172.20.0.2
Enter fullscreen mode Exit fullscreen mode

Use the following command to see more available options that you can use with the ping command.

ping -h
Enter fullscreen mode Exit fullscreen mode

Feel free to visit devtonight.com for more related content.

Discussion (0)