How to Fix "bash: ifconfig: command not found" in Ubuntu Docker Containers

In Docker on 1~3 minutes
How to Fix "bash: ifconfig: command not found" in Ubuntu Docker Containers

It is obvious, usually, we do not check or try to configure network interfaces inside of a Docker container. But there can be rare situations where we need to see the network interfaces and their IP addresses (or even ping other containers) while we are inside of a container. But the common problem with the official Ubuntu Docker image is, they come with bare minimum packages installed. So, as a result of that, tools like ifconfig and ping will not be there. But fortunately, we can install almost all the tools we need for our Docker containers, including the ifconfig command.

Before doing anything, first, we need to update our local software repository.

apt-get update

Then we need to install the ifconfig command. You might already try to install it using apt-get install ifconfig, but it will not work as expected. Because the ifconfig command comes with a different package called net-tools. So, let’s install it.

apt install net-tools

The previous command will install the ifconfig command and you will be able to use it as you usually used to do.

ifconfig

Use the -h flag to see more available options that you can use with the ifconfig command.

ifconfig -h