Can I get ip address inside my docker container?

2019-03-11 17:43发布

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 container.

7条回答
爷的心禁止访问
2楼-- · 2019-03-11 18:35

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
查看更多
登录 后发表回答