Docker Community Forums

Share and learn in the Docker community.

Docker dynamic IP

I have some issues with docker, my problem is as follows.

Currently my server environment is running in MONOLITH and planning to migrate microservices using Kubernetes and Docker.

My server ip is white listed by the third party services to call their API but in the case of DOCKER, container IP is dynamic. So it’s not possible to white list the ip frequently. Please help me to address the issue.

Easy with Docker version 1.10.1, build 9e83765.

First you need to create you own docker network (mynet123)

docker network create --subnet=172.18.0.0/16 mynet123
than simply run the image (I’ll take ubuntu as example)

docker run --net mynet123 --ip 172.18.0.22 -it ubuntu bash
then in ubuntu shell

ip addr
Additionally you could use

–hostname to specify a hostname
–add-host to add more entries to /etc/hosts
Docs (and why you need to create a network) at https://docs.docker.com/engine/reference/commandline/network_create/