ubuntu docker 映像中缺少 ip 命令[已关闭]

问题描述 投票:0回答:3

当我尝试在 ubuntu docker 容器中执行 ip 命令时,我得到:

bash:ip:找不到命令。

ubuntu版本:

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

我应该为该命令安装什么包?

谢谢

docker ubuntu
3个回答
168
投票

您可以使用

apt-file search
来确定命令在哪个包中。从我的ubuntu16.04开始,它告诉我安装
iproute2
,我认为1804类似。

0。如果

apt-file
未安装(这对于 slim docker 镜像来说很常见)

$ apt-get install apt-file
$ apt-file update

1。获取需要安装什么包:

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

2。安装包:

$ apt install -y iproute2
...

3.验证软件包是否已安装:

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

66
投票

不要忘记安装iproute2

apt install iproute2

然后你可以使用

ip
命令。


-8
投票

使用 ubuntu 最新版或任何版本映像创建 docker 并创建 ubuntu 容器后,您必须运行 ubuntu 容器并安装以下基本网络命令,

apt-get update

apt-get upgrade

apt-get install -y net-tools

apt-get update
© www.soinside.com 2019 - 2024. All rights reserved.