Docker Community Forums

Share and learn in the Docker community.

IP aliasing for a Docker container

docker

(Bobk48) #1

At the risk of sounding really newbie or stupid, can anyone tell me if you can alias Docker containers with the Linux command-

ifconfig eth0:0 192.168.5.12 netmask 255.255.255.0 up

where eth0 is the name of the nic as shown by ifconfig in the Docker container, and 192.168.0.12 is the address you want to access the container with on your LAN,

so that you can ssh into the container and out of it, from the host, or any other machine on the system, using that address?

I use this technique, for example, to make VirtualBox VM’s reachable on my LAN in Centos 7, in Ubuntu 16.04, in OpenSuse 42.1, and in PC-BSD(using the variant ifconfig etho 192.168.0.12 alias) to access iocage jails.

Any explicit and clear answer would be greatly appreciated! I have not tried this technique yet, but after considering answers as they so graciously appear here, will, and render report as explicitly as possible.

Thanks!