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

后端 未结 30 2639
小鲜肉
小鲜肉 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:32

    You can use docker inspect .

    For example:

    CID=$(docker run -d -p 4321 base nc -lk 4321);
    docker inspect $CID
    

提交回复
热议问题