ip command is missing from ubuntu docker image

DockerUbuntu

Docker Problem Overview


when i'm trying to perform ip command in ubuntu docker container, i'm getting:

> bash: ip: command not found.

ubuntu version:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"

what package should i install for that command?

Thanks

Docker Solutions


Solution 1 - Docker

You could use apt-file search to determine the command in which package. From my ubuntu16.04, it tells me to install iproute2, I think 1804 similar.

1. Get what package need to be installed:

$ apt-file search --regexp 'bin/ip$'
iproute2: /bin/ip
iproute2: /sbin/ip

2. Install the package:

$ apt install -y iproute2
...

3. Verify the package is installed:

$ dpkg -l iproute2
ii  iproute2    4.3.0-1ubuntu3      amd64      networking and traffic control tools

Solution 2 - Docker

Don't forget to install the iproute2

apt install iproute2

And then you may use ip command.

Solution 3 - Docker

Once you have created your docker with ubuntu latest or any of version image and crated a ubuntu container, you have to run your ubuntu container and install the following for the basic networking command,

apt-get update

apt-get upgrade

apt-get install -y net-tools

apt-get update

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGil KahanView Question on Stackoverflow
Solution 1 - DockeratlineView Answer on Stackoverflow
Solution 2 - DockerprostiView Answer on Stackoverflow
Solution 3 - DockerBrijesh SondarvaView Answer on Stackoverflow