zoukankan      html  css  js  c++  java
  • CentOS下Docker安装ping命令

    Docker容器里,如果我们想测试两个容器是否建立关系,我们可以用ping来测试。在默认情况下,docker的centenos镜像由于做了精简,去掉了ping命令,我们需要自己安装:

    这时会提示没有找到ping命令

    [root@localhost ~]# docker exec -it test1 /bin/bash

    root@e0e5054c2593:/# ping test2
    bash: ping: command not found

    则在容器内执行一下命令安装ping

    检查并更新:

    apt-get update

    root@e0e5054c2593:/# apt-get update

    Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
    Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
    Get:3 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [1078 B]
    Get:4 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [66.4 kB]
    Get:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]
    Get:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [207 kB]
    Get:7 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
    Get:8 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
    Get:9 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [39.1 kB]
    Get:10 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
    Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
    Get:12 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
    Get:13 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [430 kB]
    Get:14 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [17.3 kB]
    Get:15 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [202 kB]
    Get:16 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [39.3 kB]

    apt install inputils-ping

    root@e0e5054c2593:/# apt install iputils-ping
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following additional packages will be installed:
    libcap2 libcap2-bin libpam-cap
    The following NEW packages will be installed:
    iputils-ping libcap2 libcap2-bin libpam-cap
    0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
    Need to get 90.5 kB of archives.
    After this operation, 333 kB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libcap2 amd64 1:2.32-1 [15.9 kB]
    Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 libcap2-bin amd64 1:2.32-1 [26.2 kB]
    Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 iputils-ping amd64 3:20190709-3 [40.1 kB]
    Get:4 http://archive.ubuntu.com/ubuntu focal/main amd64 libpam-cap amd64 1:2.32-1 [8352 B]
    Fetched 90.5 kB in 5s (19.8 kB/s)

    以上安装成功,我们测试一下:

    root@e0e5054c2593:/# ping test2
    PING test2 (172.18.0.3) 56(84) bytes of data.
    64 bytes from test2.test-net (172.18.0.3): icmp_seq=1 ttl=64 time=0.124 ms
    64 bytes from test2.test-net (172.18.0.3): icmp_seq=2 ttl=64 time=0.089 ms
    64 bytes from test2.test-net (172.18.0.3): icmp_seq=3 ttl=64 time=0.083 ms
    64 bytes from test2.test-net (172.18.0.3): icmp_seq=4 ttl=64 time=0.566 ms
    64 bytes from test2.test-net (172.18.0.3): icmp_seq=5 ttl=64 time=0.118 ms

  • 相关阅读:
    MD5 Message Digest Algorithm in Visual Basic 6
    遍历指定文件夹的指定格式的文件并且copy到指定的文件夹下面
    宝宝的成长脚印8/17
    儿歌童谣两首
    office2003之資料編輯列的角字顯示7/10
    宝宝的成长脚印8/27
    宝宝的成长脚印7/30
    宝宝的成长脚印7/3
    LED手电筒真不咋滴8/27
    液晶显示器右边出现黑条7/7
  • 原文地址:https://www.cnblogs.com/xiangbing123/p/13564269.html
Copyright © 2011-2022 走看看