1

As a web designer I have been using VirtualBox to set up temporary work servers for my projects. Lately I've been trying to reduce the number of virtual machines on my laptop(due to limitations of SSD capacity) and I thought learning and using Docker may be beneficial in terms of system storage, deployment of finished work, and in futureproofing my skillsets. Until now, I have been using host-only adapter in addition to NAT to connect to APM server in my virtualmachine from my host(which is usualy Windows).

The following is /etc/network/interfaces setting I normally use:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# VBOX Host-only adapter
auto eth1
iface eth1 inet static
  network    192.168.56.0
  address    192.168.56.80
  netmask    255.255.255.0

I am thinking about IP aliasing to assign more IPs to the Host-only adapter(192.168.56.81, 192.168.56.82...) and routing each of them to each of the containers, which will each be running one of my projects. It looks like Docker gets to have its own network interface, docker0, which cannot be accessed from the VirtualBox host machine. From what I can tell, I have a few possible approaches:

  1. route the connection from the host to the host-only adapter to the docker0 interface
  2. somehow find a way to connect to the docker0 interface from the host machine, or
  3. somehow find a way to connect the containers to host-only interfaces

I want to know which one of these approaches is the most viable way for me to take.
I am not sure if my question if clear enough. Please let me know if I should be providing more information in order to make this question answerable.

0

In my opinion, for your usage, you shouldn't have to dig in the madness of docker networking.

I would advice you to use port mapping when you run your container.

For example, say you have created an apache image in docker through your Dockerfile. When you want to run this container, use the -p option to map ports :

sudo docker run -d -p=80:80 -p=443:443 -P apache:latest

By doing this, the local port 80 will be mapped to the port 80 of this container.

So, by accessing http://127.0.0.1 in your browser you will access your container.

If the port 80 is already used locally, you can use for example the port 8080 : -p 8080:80 and then access http://127.0.0.1:8080.

If you have multiple projects, you can use multiple ports or use virtualhosts inside your apache container and use dns alias in /etc/hosts of the hosts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.