docker容器内执行apt install net-tools

[root@localhost ~]# docker exec -ti 9d04fa294f9f /bin/bash
root@9d04fa294f9f:/# ifconfig
bash: ifconfig: command not found
root@9d04fa294f9f:/# ip addr
bash: ip: command not found
root@9d04fa294f9f:/# apt-get install ifconfig
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ifconfig
root@9d04fa294f9f:/# ping baidu.com
bash: ping: command not found
root@9d04fa294f9f:/# exit
exit
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
9d04fa294f9f        ubuntu              "/bin/sh -c 'while t…"   13 days ago         Up 32 minutes                           daemon_dc2
[root@localhost ~]# service docker restart
Redirecting to /bin/systemctl restart docker.service
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
9d04fa294f9f        ubuntu              "/bin/sh -c 'while t…"   13 days ago         Up 3 seconds                            daemon_dc2
[root@localhost ~]# docker exec -ti 9d04fa294f9f /bin/bash
root@9d04fa294f9f:/# apt-get update          
Get:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [4168 B]
Get:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]       
Get:6 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [310 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB] 
Get:8 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB]
Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB]        
Get:10 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [451 kB]
Get:11 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [5436 B]
Get:12 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]   
Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [10.8 kB]
Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1199 kB]
Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [803 kB]
Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [7236 B]
Get:17 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [942 B]
Get:18 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [3671 B]
Fetched 16.2 MB in 1min 35s (171 kB/s)                                             
Reading package lists... Done

root@9d04fa294f9f:/# apt install net-tools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  net-tools
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 194 kB of archives.
After this operation, 803 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 net-tools amd64 1.60+git20161116.90da8a0-1ubuntu1 [194 kB]
Fetched 194 kB in 3s (62.5 kB/s)    
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package net-tools.
(Reading database ... 4040 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20161116.90da8a0-1ubuntu1_amd64.deb ...
Unpacking net-tools (1.60+git20161116.90da8a0-1ubuntu1) ...
Setting up net-tools (1.60+git20161116.90da8a0-1ubuntu1) ...
root@9d04fa294f9f:/# 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 4763  bytes 16630656 (16.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3392  bytes 187637 (187.6 KB)
        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 1000  (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

转载于:https://my.oschina.net/donngchao/blog/3053979

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值