How to install “ifconfig” command in my ubuntu docker image?

前端 未结 9 1240
后悔当初
后悔当初 2021-01-30 02:50

I\'ve just installed ubuntu docker image, when I execute \"ifconfig\" it says there\'s no such command, I tried apt-get install by there\'s no package named \"ifconfig\"(I can i

相关标签:
9条回答
  • 2021-01-30 03:34

    sudo apt-get install iproute2 then run ip addr show

    it works..

    0 讨论(0)
  • 2021-01-30 03:38

    From within a Dockerfile something like the following should do the trick:

    RUN apt-get update && \
         apt-get install -y net-tools
    

    From memory it's best practice to combine the update and the package installation lines to prevent docker caching the update step which can result in out-dated packages being installed.

    Installing it via the CLI or a shell script:

    apt-get update && apt-get install net-tools

    0 讨论(0)
  • 2021-01-30 03:41

    I came here because I was trying to use ifconfig on the container to find its IPAaddress and there was no ifconfig. If you really need ifconfig on the container go with @vishnu-narayanan answer above, however you may be able to get the information you need by using docker inspect on the host:

    docker inspect <containerid>

    There is lots of good stuff in the output including IPAddress of container:

    "Networks": {
        "bridge": {
            "IPAMConfig": null,
            "Links": null,
            "Aliases": null,
            "NetworkID": "12345FAKEID",
            "EndpointID": "12345FAKEENDPOINTID",
            "Gateway": "172.17.0.1",
            "IPAddress": "172.17.0.3",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "MacAddress": "01:02:03:04:05:06",
            "DriverOpts": null
        }
    }
    
    0 讨论(0)
提交回复
热议问题