I have two containers say container1 and container2 running in same machine. I know i can communicate between both the container using link alias option. I have a scenario where i want to communicate between 2 containers using the IP address of the host machine. I have a property file in container1 where i need to provide the ip address of the container2 (Here i have to provide the ip address and not hostname of container). Everytime when i restart the container, the container ip gets changed. so is there any way to map the ip address of the host machine to link between container ?
0
votes
1 Answers
2
votes
Please check this doc which describes how to create docker network and assign IP address and range to docker container. In case of lack of time use commands below:
docker network create --subnet=192.168.0.0/16 docnet0
docker run --net docnet0 --ip 192.168.0.10 -it "your_docker_image" bash