Docker Community Forums

Share and learn in the Docker community.

Issue regarding container network

hi,
i am new to dockers. i have docker installed host machine with ubuntu 18.04 with docker. The host has one ip address on LAN network (enp1s0f0 : 192.168.17. 35) to login to the host from other system. Also, as part of docker utility, host has got docker0 interface (172.17.0.0) which is assigning ips to various containers through dhcp. Now my requirement is to have a container that will have ip adess in the range of 192.168.17.x insted of 172.17.0.0. Other containers are running with 172.17.x.x should not be disturbed.

I have tried doing

docker network create --subnet=192.168.17.0/24 mynet
docker network connect --ip 192.168.17.36 mynet mycontainer

i get interface eth1 with this ip but i am not able to ping or reach internet via this network.

i dont want to go with ip frowarding, as i want to use many ports on the container.

How to proceed in this regard?

thanks in advance.

By default a bridged network will be created. Eventhough you might think that a bridged network with the
same ip range as your lan might lead to an integration of both, it does not. Both are distinct networks.

Though, usualy people asking for what you ask, try to enforce known patterns from the vm world, to the container world. A container is not a vm!

the normal approach is to publish ports and use the host ip and published port to access the service.
If you still want to go down the road, you might want to check the docs for the network macvlan driver.