Is it possible to assign a static public ip to a Docker Container?

前端 未结 3 1874
天涯浪人
天涯浪人 2021-01-28 02:38

I have been trying to assign one of my five public ip\'s to my docker container. It seems like this should be possible because of the nature of docker and its uses. I found this

3条回答
  •  青春惊慌失措
    2021-01-28 03:35

    Docker 1.10 will allow you to specify a static IP-address for a container for each network it's connected to.

    (Note that, for backward compatibility, this feature is only supported for custom networks, and only if a subnet is specified)

    For example;

    docker network create -d bridge --subnet 172.25.0.0/16 mynet
    
    docker run -d --net=mynet --ip=172.25.3.3 nginx
    

    For more information see the documentation pull request

提交回复
热议问题