I want to assign static ip to my docker container in docker for Window for linux container. I have achieved same in linux container using macvlan but macvlan doesn't support for docker for Windows. Does any one have work around how can i assign static ip to my linux container so it directly expose to outside world without port mapping. I have also tried to use transperent driver in window container with LCOW enabled but as my application need privileged and bind mount to cgroup window container can not be used. Note:I have specific scenario to use static ip as port mapping is not working for my application.
1 Answer
You need create user define network
docker network create -d transparent --subnet=10.1.1.0/24 --gateway=10.1.1.1 TransparentNet3
Then you need run container with key --ip
docker run -it --name nano03 --network=TransparentNet3 --ip 10.1.1.1 someimage:sometag
-
1Transparent driver only work when we are running docker in window mode(switch to window container option).As i have already mention above my application can't run in window docker mode.I have to run in linux mode(switch to linux container option).– chetanCommented Sep 10, 2018 at 15:08
-
1why you need static ip. user dns he host has a changing IP address (or none if you have no network access). From 18.03 onwards our recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host. This is for development purpose and will not work in a production environment outside of Docker for Windows. The gateway is also reachable as gateway.docker.internal. Commented Sep 10, 2018 at 16:56
-
1Static ip is need of my application.My application has three way handshake and it's failing as it docker ip cannot be reached from outside world.– chetanCommented Sep 11, 2018 at 4:45