Making docker available to external world from VM

Needles to say i am coding on Windows quite plenty of time. But for deploying goals i always in preference of using Docker running on Ubuntu, Vagrant or other linux systems. If you apply a similar approach then the one of the first challenges you will certainly face is accessing Docker from Virtual box. But don’t worry! I will explain how to deal with it below.

Admitting that you already installed Docker on VM everything are left to do is a bit of configuration changes.

First thing you need is to allow any connections to docker via external port. Open file for editing :

/etc/systemd/system/docker.service.d

Add line listed below to the end ExecStart = option :

 ExecStart= -H tcp://0.0.0.0:2375

Then restart docker service with the command:

sudo systemctl daemon-reload 
sudo systemctl restart docker.service

Check that port 2375 is listened by docker with command:

  sudo netstat -lnp | egrep '2375'

Now you need to configure the port forwarding from Virtual box machine. Open Settings => Network and check that Network adapter attached to NAT. Then move to Advanced => Port forwarding and add docker rules as depicted on a picture:

After that your docker machine should be available via address

 tcp://127.0.0.1:2375

Leave a Reply

Your email address will not be published. Required fields are marked *