Katebright
New Member
Hi guys,
I am presently working on my end of course project in linux. I want to deploy 2 haproxy and 2 web servers using docker containers.
My worry is i am unable to setup static IP addresses for my containers and the fact is that they automatically obtain IPs through dhcp which is not adapted to my actual network plan.
Can someone help me on how to go about it please?
I used the following commands to create my network and run my containers:
Docker network create –drive=bridge –subnet 192.168.10.0/24 mylan
# to create mylan which is my network
Docker run - d --name ct-web1 --network mylan ubuntu /bin/bash
Docker run - d --name ct-web1 --network mylan ubuntu /bin/bash
Docker run - d --name ct-haproxy1 --network mylan debian /bin/bash
Docker run - d --name ct-haproxy2 --network mylan debian /bin/bash
# to create my containers and in a specified network
For my router i used the following
Docker run - d --name ct-router --network host debian /bin/bash
Docker network connect mylan ct-router
Are they other instructions that i can use in order to get static IPs ? because when i use the above instructions, my containers will end up taking dynamic addresses even though on the defined network above but i prefer to make it static and fix
Below is an attached structure of my network plan to help you understand
Thank you for your help
I am presently working on my end of course project in linux. I want to deploy 2 haproxy and 2 web servers using docker containers.
My worry is i am unable to setup static IP addresses for my containers and the fact is that they automatically obtain IPs through dhcp which is not adapted to my actual network plan.
Can someone help me on how to go about it please?
I used the following commands to create my network and run my containers:
Docker network create –drive=bridge –subnet 192.168.10.0/24 mylan
# to create mylan which is my network
Docker run - d --name ct-web1 --network mylan ubuntu /bin/bash
Docker run - d --name ct-web1 --network mylan ubuntu /bin/bash
Docker run - d --name ct-haproxy1 --network mylan debian /bin/bash
Docker run - d --name ct-haproxy2 --network mylan debian /bin/bash
# to create my containers and in a specified network
For my router i used the following
Docker run - d --name ct-router --network host debian /bin/bash
Docker network connect mylan ct-router
Are they other instructions that i can use in order to get static IPs ? because when i use the above instructions, my containers will end up taking dynamic addresses even though on the defined network above but i prefer to make it static and fix
Below is an attached structure of my network plan to help you understand
Thank you for your help
Attachments
Last edited: