Mastodon

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=172.10.0.0/16 --ip-range=172.10.1.0/24 --gateway=172.10.1.254 private

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

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

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

View the available network using command

  docker network ls

 

[tweetthis]Assign static ip to docker container[/tweetthis]

 

 

Leave a Reply

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