With the base ubuntu:12.04
, ifconfig
is not available in the container, though the ip
command is available, why is this? and, how to get ifconfig
in the container?
You can install ifconfig with apt-get install net-tools
. (Specifically, by adding RUN apt-get install -y net-tools
to your Dockerfile.)
Based on my test, ifconfig is included in ubuntu:14.04.
Unless and until you can install net-tools, there is no need to give it by default. Also if you want to see the IP address then there is another command available by docker itself:-
docker inspect <container_name or container_id>
docker inspect syntax: docker inspect [OPTIONS] NAME|ID [NAME|ID...]
This cmd will show you every detail of running container including IP address.
I also stumbled on this nuisance, but as Devendra wrote in docker inspect you can get all details about the container without net-tools
.
In my case I needed the container's IP.
To extract the IP you can use:
docker inspect <container-id> \
| grep "\"IPAddress\"" -m 1 \
| grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'
EDIT even shorter notation to get container's IP (see docker inspect examples):
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container-id-or-name>
You can install it using
apt-get install net-tools
or if you are using redhut linux install it using yum package manager
yum install net-tools
Are the developers still alive? This was deprecated years ago.
“Some programs” and “there is bug”: can you be more specific?
I am aware that ifconfig
is somehow deprecated, but some programs still depend on it.
There is bug when using ip
in the current version of the software. I need a quick workaround of the problem.