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?
- 953
- 1
- 7
- 7
-
6See [Linux Networking - “ip X” instead of ifconfig/route/etc?](http://serverfault.com/q/42047/126632) and [Should I quit using Ifconfig?](http://serverfault.com/q/458628/126632) – Michael Hampton Jul 18 '14 at 04:16
-
I am aware that `ifconfig` is somehow deprecated, but some programs still depend on it. – Pellaeon Jul 18 '14 at 04:20
-
3Are the developers still alive? This was deprecated years ago. – Michael Hampton Jul 18 '14 at 04:21
-
There is bug when using `ip` in the current version of the software. I need a quick workaround of the problem. – Pellaeon Jul 18 '14 at 04:27
-
1"Some programs" and "there is bug": can you be more specific? – Mark Wagner Jul 18 '14 at 06:32
4 Answers
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.
- 1,346
- 1
- 9
- 4
-
6Still makes me wonder why it's not included by default, but I suppose the point of this container is that it's as minimal as it possibly can be and still work. – Iguananaut Feb 04 '16 at 16:27
-
6Another addendum--on a fresh instance of the Ubuntu container the package lists are not populated either, so you must run `sudo apt-get update` if you haven't already. – Iguananaut Feb 05 '16 at 08:25
-
2
-
13To answer @Iguananaut: An Ubuntu VM is 500+ MB, whereas an Ubuntu Docker image is less than 100MB. Guys creating containers images need to draw a line as to what packages/binaries should be included and what not, so as to keep only the basic necessities inside. You know, all of this makes more sense if you think containers as processes, and not as an 'isolated computing environment to play inside and about' – Rushi Agrawal Jul 21 '16 at 08:50
-
-
will recommend to install telnet as well (apt-get install telnet) for testing port and host – Nusrat Nuriyev Jan 04 '22 at 23:23
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.
- 233
- 3
- 6
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>
- 55
- 1
- 5
-
This will however not work inside the container, as the OP requested. – Gerald Schneider Jun 22 '17 at 07:53
-
You're right. Just seem like a useful tip, and I thought that OP was most likely also looking to find the container's IP. – Obeyed Jun 22 '17 at 19:58
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
- 21
- 1