Is it possible to assign a static public ip to a Docker container?

I am trying to assign one of my five public ip to my docker container. It seems like this should be possible due to the nature of the docker and its use. I found this site which, I think, explains what I want to do, but it doesn’t work anymore since Docker left LXC:

http://programster.blogspot.com/2014/06/docker-run-multiple-docker-websites-on.html

I tried to make a static NAT connection with ip used by my container, but this did not work. The IP address of the dock is not displayed on my routers page, but only the IP addresses of the host computers.

My questions:

Is it possible to assign a static public ip to the docker container, and if so, how?

and

Is it possible to make the IP address of the dock on my router configuration page, and if so, how?

Thanks.

0
source share
3 answers

Possible solution, but I can not check it right now. Please let me know if this is not true.

Make a virtual network interface using macvlan:

See https://superuser.com/questions/175475/ip-address-alias-assigned-by-dhcp

commands:

ip link add dev macvlan0 link eth0 type macvlan # macvlan0 being v-card name (lol)

Connect the container to the virtual network interface using the protocol:

see https://github.com/jpetazzo/pipework/#connect-a-container-to-a-local-physical-interface

commands:

pipework macvlan0 $ ($ containerid) dhcp

0

Docker 1.10 IP- , .

( , , )

:

docker network create -d bridge --subnet 172.25.0.0/16 mynet

docker run -d --net=mynet --ip=172.25.3.3 nginx

.

+1

, , - ip, - pipework.

, DHCP - . , " ". nspawn, systemd, FWIW.

0

Source: https://habr.com/ru/post/1620243/


All Articles