Can I get ip address inside my docker container?

后端 未结 9 1806
南旧
南旧 2020-12-28 12:10

How to get container ip address inside this container?

\'docker inspect $hostname ...\' not suitable, because I don\'t share /var/run/docker.sock host file to contai

9条回答
  •  一个人的身影
    2020-12-28 12:39

    Normally you can use the linux program ifconfig to get IP addresses and other networking details. Your container may not have it, in which case you'll need to install it via apt-get or yum or your distro's package manager. A basic pipeline to get the IP address would be

    ifconfig eth0 | grep "inet addr:" | cut -d : -f 2 | cut -d " " -f 1
    

提交回复
热议问题