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
Then install the ping
command. It comes with the iputils-ping
package.
apt-get install iputils-ping
After that, you will be able to use the ping
command as you normally used it.
ping 172.20.0.2
Use the following command to see more available options that you can use with the ping
command.
ping -h