欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Docker的ubuntu镜像安装的容器无ifconfig和ping命令的解决

程序员文章站 2024-02-02 10:30:52
...

亲测可以解决但是再次运行ubuntu就不行了还需要重装,还未解决:
博主最近真的是天天踩坑:

[root@foundation38 tidb]# docker run -it --name vm1 ubuntu
root@6ac61d6d507e:/# ping vm1   ubuntu镜像没有ping和ip命令
bash: ping: command not found
root@6ac61d6d507e:/# ip addr 
bash: ip: command not found
root@6ac61d6d507e:/# exit
exit

Docker的ubuntu镜像安装的容器无ifconfig和ping命令的解决

[root@foundation38 tidb]# docker run -it --name vm2 ubuntu
root@a77e06da9b86:/# apt-get update
root@a77e06da9b86:/# apt install net-tools   安装ifconfig
root@a77e06da9b86:/# apt install iputils-ping  安装ping

测试:

aaa@qq.com:/# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 19573  bytes 27511619 (27.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 19440  bytes 1738567 (1.7 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

aaa@qq.com:/# ping vm2
PING vm2.ilt.example.com (220.250.64.20) 56(84) bytes of data.
^C
--- vm2.ilt.example.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 1999ms

Docker的ubuntu镜像安装的容器无ifconfig和ping命令的解决