Docker Mac Virtual Machine



A Docker Machine is a virtual machine running under VirtualBox in your host machine. We can use the Port Forwarding feature of VirtualBox in order to access the Docker VM as localhost. To achieve this do the following: First of all, make sure your Docker Machine is stopped by executing the following. Docker Machine is a tool that lets you install Docker Engine on virtual hosts, and manage the hosts with docker-machine commands. You can use Machine to create Docker hosts on your local Mac or Windows box, on your company network, in your data center, or on cloud providers like AWS or Digital Ocean.

Christian Nadeau | January 24, 2017 | 4 Min Read

When using a containerized application, it’s important to be able to easily deploy them in the cloud. Docker-Machine is a tool that lets you install Docker Engine on Virtual Hosts. We’ll outline how we deploy containers and how to transfer files to/from the machine.

What is docker-machine?

When you have a containerized application, it’s important to be able to easily deploy them in the cloud, not only running them locally using Docker for Mac/Windows or from a Linux box locally. The tool to be able to create a remote virtual machine (VM) easily and manage those containers is called docker-machine.

In short, it allows you to control the docker engine of a VM created using docker-machine remotely. It even allows you to update the docker engine, restart the virtual machine (depending if the driver supports it), view its state and so on.

The main reason you would use docker-machine is when you want to create a deployment environment for your application and manage all the micro-services running on it. For instance, you can easily have a development, staging and production environment accessible from your own machine and update them accordingly.


The drivers concept acts as a connector to 3rd party services such as Azure, Amazon, etc. This allows you to create a complete set of resources around the actual VM in order to easily manage it from each service’s admin portal. There is also the generic driver which allows you to convert an actual virtual machine into a docker-machine.

NOTE: Reference material may be downloaded here

Machine

How to create a docker machine?

Azure

This will create a virtual machine on Azure and install docker engine on it.

VERY IMPORTANT:

This command will DELETE the Azure virtual machine and all related resources from your subscription! Use it with care.

VirtualBox

This will create a virtual machine on your local VirtualBox instance and install docker engine on it.

Mac

Generic

This will use the public identification key in order to connect to an existing machine (virtual or not) and install docker engine on it.

NOTE: This driver does not yet allow you to restart/shutdown the system.

You have a docker-machine VM, now what?

NOTE: We’ll suppose the docker-machine is created, reachable and named demo-machine

Machines

Here is a simple docker-compose.yml example:

Deploy containers locally

Start this hello world docker-compose locally:

You can curl it locally and see the content of the index.html page:

Now stop and delete the created container of the locally started docker-compose:

Deploy containers to a remote host

Let’s do the same thing but on the remote demo-machine.
Change the local docker environment variables to the demo-machine ones:

You’re now targeting demo-machine when using any docker commands. To validate which docker-machine you point to, use this command:

Start the same hello world docker-compose defined locally:

Try to curl locally:

Create Docker Machine

The docker commands are not run locally, they are run on the docker-machine we just configured! You must use the IP of the docker-machine itself as follow:

SSH

Once the machine is created, it’s really easy to ssh into it because the SSH certificates are generated on the machine and kept locally:

Copy files to/from the machine

You can use SCP command to send/receive files to/from the machine.

Here is how to copy ~/localfile.txt into the home folder of the demo-machine

Here is how to copy ~/remote.txt from the home folder of the demo-machine to the local home folder:

Docker Mac Virtual Machine

Cleaning up the local docker environment

If you want to go back to your local instance:

To validate:

Get Email Updates

Get updates and be the first to know when we publish new blog posts, whitepapers, guides, webinars and more!

Suggested Stories

Guide to Creating Engaging Digital Health Software

This guide shares our knowledge and insights from years of designing and developing software for the healthcare space. Focusing on your user, choosing the right technology, and the regulatory environment you face will play a critical role in the success of your application.

Read More

Accelerate Time To Market Using Rapid Prototyping

In this webinar, you will learn how to leverage rapid prototyping to accelerate your products time to market in one week, agile sprints.

Read More

WebRTC: Top 5 Unified Communications Systems Integration Challenges

Docker Mac Virtual Machine Free

WebRTC is looking to be a game changer in terms of its impact on voice and data communications.

Read More

Docker Mac Os X Virtual Machine

Recently i got a new macbook pro and i started setting it up. Everything was going great until i tried to install docker and create default docker machine. After i installed Docker for Mac, i tried to start virtual machine :

After some googling i found couple of solutions for the problem :

Docker Mac Virtual Machine Download

  1. Reinstall VM and then restart computer
  2. Install older version of VM, install it and then restart computer
  3. Restart VirtualBox

Tried all of them and everytime it was a failure. One thing was not leaving me in piece - when i was re-installing VirtualBox i was getting an error during installation :
Still, i was able to launch VirtualBox UI and even see that default machine was created. Though, when i tried to start it - i was getting driver not installed (rc=-1908) error. This got me to one thread, where i found a suggestion to check Mac OS Privacy settings and check if VirtualBox software was asking for permissions or not. And that was it ! So, to fix this problem you just have to :

  1. Start VirtualBox installation
  2. Wait for it to Fail
  3. Open Settings->Security&Privacy
  4. On the bottom there will be a record that System software from 'Oracle' developer was blocked from loading
  5. Tap Allow button
  6. Install VirtualBox again.

At the end you should have a Successful installation of VirtualBox and now you can

Now you just need to docker-machine env default and you are all set.

Happy coding ! :)