docker with docker-machine


Docker is container technology which is specifically made for Linux. If you do not know what docker is…please google it, there are many articles which do a great job explaining what it is.
Through Virtualization technology it is possible to run a Docker deamon/ environment on your windows or mac osx environment as well. Initially this project was called boot2docker…but for a while now it is called docker-machine.

With docker-machine and the azure driver you can have a “local” docker environement which seemlessly integrates with your azure cloud. Everything you deploy on this environment is directly available via Azure.


No more configuration issues, scripting and deploying stuff. You build your code and make it available in a container…you know it works, you pick up the container and make it available on a cloud provider. It does not get any clearer and easier than that at the moment.

note: soon there will be native docker for macosx and windows, so there will be no need for docker-machine. It will even get easier to integrate then.


The steps documented in this blog can be viewed with this youtube flic: Youtube
The sources: for the webapplication (with the docker-maven-plugin) can be found here: Github

This article asumes you have a jdk(>1.7) and maven(> 3.0) installed, a git client and if you work on a windows or macOsx OS docker-machine in combination with virtualbox. For Linux guys having the docker daemon running is enough. Get the sources used by this article from the following location: or get everything by typing: git clone


go to the directory containing the sources: cd ./rss_bookmarker and look at the maven pom.xml file…
this part plugin does the magic for you, the following example does the following: 

it will create a docker image with the name cvugrinec/rss_bookmarker:[ with the defined version ]
This image is based on another image which resides in dockerhub under cvugrinec/wildfly: This image contains centos with a jdk container named wildly (the community version of jobs). The war of your webapplication is described in a file called assembly.xml. All the refered artifacts in the assembly.xml file will be copied to the /opt/jboss/wildfly/standalone/deployments folder and thus be deployed automatically.
While creating the image it will run some commands. The command in the example below creates a user in a file; wildly uses this file for authentication and authorization. The user in the example is: chris with password jboss4All, of course you are free to change this to your likings.  At last this amazing plugin can do path mapping as well for you, in the example below it maps the /opt/rssfiles folder in the docker container to your local temp folder. 












          <maintainer>[email protected]</maintainer>








            <run>/opt/jboss/wildfly/bin/ -a chris jboss4All</run>

            <run>sed -i ‘s/microsoft/chris/g’ /opt/jboss/wildfly/standalone/configuration/</run>





















Local test

Test this application locally by running the following commands:

create your local docker environment (don’t need to if you already have one)

   docker-machine create -d virtualbox ms-acs-demo1

make your environment use the docker daemon on the created docker-machine

   docker-machine start ms-acs-demo1

   eval (docker-machine env ms-acs-demo1)

Compile your sources

mvn clean install 

Executes the tasks from the docker-maven-plugin, creating docker images

mvn docker:build 

Start the docker instance (with your app

docker run -d -p 8888:8080 cvugrinec/rss_bookmarker:1.5

If you like you can check the logs with docker logs -f [docker instance id] command. In order to test this locally you have to make sure that your virtualbox instance allows port 8888, you can set this by going to your settings of your virtual box machine, go to your network settings, avanced settings and then do a port forward from 8888 to 8888. Of course your are free to use antoher port as well.



now you can go to your browser and type the following: http://localhost:8888/rss-bookmarker, you will see this wonderful page then:


Now on Azure!!!

In order to setup your local environment to do docker deployments on azure with docker-machine, you need to setup authentication. The easiest way to do this is via these commands:

azure login , just follow the steps in the dialogue. Then download an azure file which can be used for authentication with the following command: azure account download

Create the docker machine on azure with the following command 

docker-machine create -d azure –azure-subscription-id=[ “YOUR SUBSCRIPTION ID” ] –azure-location=[ “YOUR DESIRED GEO LOCATION” ] –azure-publish-settings-file=[ “YOUR AUTHENTICATION FILE” ] [ “NAME OF YOUR MACHINE” ]
for e.g.
docker-machine create -d azure –azure-subscription-id=”4adba00c-de3d-4526-a290-0c4fa2421f84″ –azure-location=”West Europe” –azure-publish-settings-file=”chris.publishsettings” chris-acs-demo4

After a couple of minutes your container will be available in azure, in the example above the container will be availble via this DNS name:

load your environment variables:


export DOCKER_HOST=”tcp://$″

export DOCKER_CERT_PATH=”/Users/chris/.docker/machine/machines/$machine”

export DOCKER_MACHINE_NAME=”$machine”


where $machine is the name of the machine you just created 

After you loaded your azured docker environment you can do the same stuff you did earlier with the java application: mvn docker:build and then run it with docker run -d -p 8888:8080 cvugrinec/rss_bookmarker:1.5 command.

If you like to make your application publically availble you need to open a public port and map this to the docker instance port. You can do this with the following command:

create endpoint azure vm endpoint create chris-acs-demo4 80 8888

now you can access the application with your browser