Docker 如何使用';ping&x27;论软呢帽码头工人
在容器根目录中键入Docker 如何使用';ping&x27;论软呢帽码头工人,docker,Docker,在容器根目录中键入 ping 得到 bash: ping: command not found 然后我打字 yum install iputils ping 然后我打字 yum install iputils ping 我得到 bash: /usr/bin/ping: Operation not permitted bash: sudo: command not found sudo: unable to execute /bin/ping: Operation not perm
ping
得到
bash: ping: command not found
然后我打字
yum install iputils
ping
然后我打字
yum install iputils
ping
我得到
bash: /usr/bin/ping: Operation not permitted
bash: sudo: command not found
sudo: unable to execute /bin/ping: Operation not permitted
那我会的
sudo ping
sudo ping
我得到
bash: /usr/bin/ping: Operation not permitted
bash: sudo: command not found
sudo: unable to execute /bin/ping: Operation not permitted
所以我打字
yum install sudo
我打字
我得到
bash: /usr/bin/ping: Operation not permitted
bash: sudo: command not found
sudo: unable to execute /bin/ping: Operation not permitted
在这一点上,我放弃了,把我的手举在空中
那么我如何使用
ping
util,我还想使用其他util,比如hostname
和ifconfig
它可以与最新的fedora一起使用
$ docker run -it fedora /bin/bash
Unable to find image 'fedora:latest' locally
latest: Pulling from library/fedora
01eb078129a0: Pull complete
Digest: sha256:8ee55e140e8751492ab2cfa4513c82093cd2716df9311ea6f442f1f1259cbb3e
Status: Downloaded newer image for fedora:latest
[root@5eee4a163a0e /]# pwd
/
[root@5eee4a163a0e /]# ping
bash: ping: command not found
[root@5eee4a163a0e /]# yum install iputils
Fedora Modular 29 - x86_64 349 kB/s | 1.5 MB 00:04
Fedora Modular 29 - x86_64 - Updates 291 kB/s | 2.1 MB 00:07
Fedora 29 - x86_64 - Updates 4.3 MB/s | 25 MB 00:05
Fedora 29 - x86_64 5.0 MB/s | 62 MB 00:12
Dependencies resolved.
============================================================================================================================================================================================================
Package Architecture Version Repository Size
============================================================================================================================================================================================================
Installing:
iputils x86_64 20180629-2.fc29 fedora 130 k
Transaction Summary
============================================================================================================================================================================================================
Install 1 Package
Total download size: 130 k
Installed size: 334 k
Is this ok [y/N]: y
Downloading Packages:
iputils-20180629-2.fc29.x86_64.rpm 84 kB/s | 130 kB 00:01
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 45 kB/s | 130 kB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : iputils-20180629-2.fc29.x86_64 1/1
Running scriptlet: iputils-20180629-2.fc29.x86_64 1/1
Verifying : iputils-20180629-2.fc29.x86_64 1/1
Installed:
iputils-20180629-2.fc29.x86_64
Complete!
[root@5eee4a163a0e /]# ping
Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface]
[-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]
[-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]
[-w deadline] [-W timeout] [hop1 ...] destination
Usage: ping -6 [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface]
[-l preload] [-m mark] [-M pmtudisc_option]
[-N nodeinfo_option] [-p pattern] [-Q tclass] [-s packetsize]
[-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline]
[-W timeout] destination
[root@5eee4a163a0e /]#
安装*iputils后,应设置CAP\u NET\u RAW
功能:
sudo setcap cap_net_raw+p /bin/ping
根据:
默认情况下,凡人没有帽子
我很惊讶这能奏效。Ping需要能够构造ICMP数据包,如果恶意使用,这些数据包可能会对网络造成严重破坏,因此这些数据包仅限于管理员用户。Docker设置允许容器执行管理级操作?看起来不安全。@ZanLynx不,他只是以
root
的身份打开了容器。此时,系统假设他知道自己在做什么:)你如何进入容器?通常你不会以这种方式使用Docker;相反,您需要安装所需的特定工具集。作为一般规则,永远不要在容器中的交互式shell中安装软件:一旦容器退出,您将失去一切。