Multiple IP Addresses for Conatiner

499 views
Skip to first unread message

Dhiraj Kasliwal

unread,
Oct 10, 2014, 9:24:52 AM10/10/14
to docke...@googlegroups.com
I wanna give multiple address for single container for single container . But as soon as i give addresses I am unable to reach gateway of that address .
Is anyone given multiple addresses in single container?

Sven Dowideit

unread,
Oct 12, 2014, 9:46:36 PM10/12/14
to docke...@googlegroups.com
I'm not sure what you mean - containers typically talk to the private docker0 bridge

Its probably worthwhile reading https://docs.docker.com/articles/networking/ to see what options Docker makes available, and if thats not quite enough, https://github.com/jpetazzo/pipework contains some other tricks that may help you

can you be more specific about what you're working to acheive?

Sven

Dhiraj Kasliwal

unread,
Oct 13, 2014, 12:43:01 AM10/13/14
to docke...@googlegroups.com
Thanks for your reply. Actually I wanna make docker container as Load-Balancer. For that I need live IP inside container and my server directly contact with container.

Sven Dowideit

unread,
Oct 13, 2014, 11:07:01 PM10/13/14
to docke...@googlegroups.com
in that case, `--net host` might give you the control you need :)

Jens Schutt

unread,
Oct 23, 2014, 7:01:48 PM10/23/14
to docke...@googlegroups.com
You can set up another vnic for that container. Not that it is pretty, but ....

$ export CONTAINER_NAME=myDockerContainer

$ export PID=`docker inspect -f '{{.State.Pid}}' $CONTAINER_NAME 2> /dev/null` 

$ ip link add veth${PID}_eth0 type veth peer name peer${PID}_eth0

$ ip link set veth${PID}_eth0 up

$ export MAC=`ip link show peer${PID}_eth0 | grep link/ether | sed "s/^ *link\/ether //" | sed "s/ brd.*//"`

$ mkdir -p /var/run/netns

$ ln -s /proc/${PID}/ns/net /var/run/netns/$CONTAINER_NAME

$ ip link set peer${PID}_eth0 netns $CONTAINER_NAME

$ ip netns exec $CONTAINER_NAME ip link set dev peer${PID}_eth0 name eth1

$ ip netns exec $CONTAINER_NAME ip link set eth1 up

$ ip netns exec $CONTAINER_NAME ip addr add 192.0.0.10/20 dev eth1

Sven Dowideit

unread,
Oct 23, 2014, 11:26:46 PM10/23/14
to docke...@googlegroups.com
Nice job Jens!

is there any chance you'd be willing to add some prose around that and make a PR against

https://docs.docker.com/articles/networking/

I'm thinking it would be pretty neat to have an example that shows binding a real `eth1` against one container - and thats really just a small change from your description (and very similar to the point to point example really)

Sven

Dhiraj Kasliwal

unread,
Nov 2, 2014, 10:20:03 AM11/2/14
to docke...@googlegroups.com
Thanks Sven and Jens for your answer.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "docker-dev" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/docker-dev/Haph3k6GXHc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> docker-dev+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages