in Education by
Since Docker 1.10 (and libnetwork update) we can manually give an IP to a container inside a user-defined network, and that's cool! I want to give a container an IP address in my LAN (like we can do with Virtual Machines in "bridge" mode). My LAN is 192.168.1.0/24, all my computers have IP addresses inside it. And I want my containers having IPs in this range, in order to reach them from anywhere in my LAN (without NAT/PAT/etc...). I obviously read Jessie Frazelle's blog post and a lot of others post here and everywhere like : How to set a docker container's iP? How to assign specific IP to container and make that accessible outside of VM host? and so much more, but nothing came out; my containers still have IP addresses "inside" my docker host, and are not reachable for others computers on my LAN. Reading Jessie Frazelle's blog post, I thought (since she uses public IP) we can do what I want to do? Edit: Indeed, if I do something like : network create --subnet 192.168.1.0/24 --gateway 192.168.1.1 homenet docker run --rm -it --net homenet --ip 192.168.1.100 nginx The new interface on the docker host (br-[a-z0-9]+) take the '--gateway' IP, which is my router IP. And the same IP on two computers on the network... BOOM Thanks in advance. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
EDIT : This solution is now useless. Since version 1.12, Docker provides two network drivers : macvlan and ipvlan. They allow assigning static IP from the LAN network. See the answer below. After looking for people who have the same problem, we went to a workaround : Sum up : (V)LAN is 192.168.1.0/24 Default Gateway (= router) is 192.168.1.1 Multiple Docker Hosts Note : We have two NIC : eth0 and eth1 (which is dedicated to Docker) What do we want : We want to have containers with ip in the 192.168.1.0/24 network (like computers) without any NAT/PAT/translation/port-forwarding/etc... Problem When doing this : network create --subnet 192.168.1.0/24 --gateway 192.168.1.1 homenet we are able to give containers the IP we want to, but the bridge created by docker (br-[a-z0-9]+) will have the IP 192.168.1.1, which is our router. Solution 1. Setup the Docker Network Use the DefaultGatewayIPv4 parameter : docker network create --subnet 192.168.1.0/24 --aux-address "DefaultGatewayIPv4=192.168.1.1" homenet By default, Docker will give to the bridge interface (br-[a-z0-9]+) the first IP, which might be already taken by another machine. The solution is to use the --gateway parameter to tell docker to assign a arbitrary IP (which is available) : docker network create --subnet 192.168.1.0/24 --aux-address "DefaultGatewayIPv4=192.168.1.1" --gateway=192.168.1.200 homenet We can specify the bridge name by adding -o com.docker.network.bridge.name=br-home-net to the previous command. 2. Bridge the bridge ! Now we have a bridge (br-[a-z0-9]+) created by Docker. We need to bridge it to a physical interface (in my case I have to NIC, so I'm using eth1 for that): brctl addif br-home-net eth1 3. Delete the bridge IP We can now delete the IP address from the bridge, since we don't need one : ip a del 192.168.1.200/24 dev br-home-net The IP 192.168.1.200 can be used as bridge on multiple docker host, since we don't use it, and we remove it.

Related questions

0 votes
    Which Ansible module is used to manage docker services and containers. (i)docker_login (ii)docker_container (iii)docker (iv)docker_service...
asked Jan 25, 2023 in Technology by JackTerrance
0 votes
    Which Ansible module is used to manage docker services and containers (i)docker_login (ii)docker_container (iii)docker (iv)docker_service...
asked Jan 24, 2023 in Technology by JackTerrance
0 votes
    Do I need to use separate Docker containers for my complex web application or I can put all required services in ... in one container? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    My docker-compose file has some running docker files to create my containers. I don't want the docker files ... docker-compose syntax? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    How many containers can run in docker and what are the factors influencing this limit?...
asked Jun 21, 2021 in Technology by JackTerrance
0 votes
    What is the docker command that lists the status of all docker containers?...
asked Jun 18, 2021 in Technology by JackTerrance
0 votes
    Running Docker containers can be checked by using___________. (1)docker ps (2)docker cs...
asked May 2, 2021 in Technology by JackTerrance
0 votes
    What is the default IP address of the Docker host? 1. 0.0.0.0 2. 127.0.0.1 3. 192.168.99.100 4. 192.127.99.1...
asked Jun 22, 2021 in Technology by JackTerrance
0 votes
    When I run telnet command in Docker it does not run. Could you please tell me how to install ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    Q.2 Which mode of IPsec should you use to assure the security and confidentiality of data within the same LAN? A. ESP ... AH transport mode C. AH tunnel mode D. ESP tunnel mode...
asked Mar 12, 2023 in Technology by JackTerrance
0 votes
    LAN formed using wifi or any other wireless medium is known as ______. Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    What is Network? State advantages of Network. Explain features of LAN Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    Which virus from the following can be spread through LAN net work? a)stoned virus b) Sunday c) Brain d)mellissa ... or I will report Select the correct answer from above options...
asked Dec 2, 2021 in Education by JackTerrance
0 votes
    Which Virus among the following can be spread through LAN network? a) Stoned Virus b) Sunday c) Brain d) Melissa Select the correct answer from above options...
asked Dec 2, 2021 in Education by JackTerrance
0 votes
    LAN covers more distance as compared to wan_________ true ir false Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
...