Assign static ip to docker container

At the core, docker does not allow you to assign static ip to its containers.  You can do so but by defining your own private network.  Below tutorial does this:

First of all, you need to define your own network.  Something like below:

  docker network create --driver=bridge --subnet= --ip-range= --gateway= private

Next all is left is, pass below arguments to your run command.

  docker run --network=private  --ip --name container_name container_to_launch

This way your container gets a static ip address which is in this case.

View the available network using command

  docker network ls




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.