How to get a Docker container's IP address from the host

后端 未结 30 2652
小鲜肉
小鲜肉 2020-11-22 08:45

Is there a command I can run to get the container\'s IP address right from the host after a new container is created?

Basically, once Docker creates the container, I

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 09:31

    In Docker 1.3+, you can also check it using:

    Enter the running Docker (Linux):

    docker exec [container-id or container-name] cat /etc/hosts
    172.17.0.26 d8bc98fa4088
    127.0.0.1   localhost
    ::1 localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    172.17.0.17 mysql
    

    For windows:

    docker exec [container-id or container-name] ipconfig
    

提交回复
热议问题