how to properly specify an IP for a docker container

后端 未结 3 1943
天命终不由人
天命终不由人 2021-01-25 20:25

I\'m trying to explicitly specify an IP address for my docker container in the following way:

sudo docker run -it -p 172.17.0.2:10000:10000 -p 9000:9000 -p 9090:         


        
3条回答
  •  再見小時候
    2021-01-25 20:38

    The -p argument is used to forward ports from the container to the host, not for assigning IPs.

    There is no easy way to assign a fixed IP to a Docker container and I would strongly advise you not to try. Instead re-architect your system so that it isn't dependent on a fixed IP. If this really isn't possible, I think you can choose an IP by using the LXC execution driver and various flags, but I would strongly recommend against this.

提交回复
热议问题