3 May 2015

Docker Machine Example

Here's a quick setup guide using Docker Machine to setup a Confluence server but this example could be used for any other application.
I'd like to quickly get an Atlassian Confluence server going using Docker Machine and I'll be using an existing docker repository by cptactionhank.. I'm going to assume you've installed Docker Machine and it's dependencies and that you don't already have a machine setup to run the container on.

Note that in these command examples, I've created a softlink from /usr/local/bin/machine to /usr/local/bin/docker-machine.

Machine Setup

First let's create the machine and verify it's been created. We'll call the machine dev.

[shell linenumbers=false]
machine create --driver virtualbox dev
machine ls
[/shell]

Container Setup

Now that we have a machine to run on, let's get our docker container with Confluence up and running. The first thing we have to do, is tell docker that we want to work with the dev machine that we setup with the machine command.

[shell linenumbers=false]
eval "$(docker-machine env dev)"
docker ps
machine env dev
[/shell]

Now that docker is pointing to the correct machine environment, let's get the container going:
[shell linenumbers=false]
docker pull cptactionhank/atlassian-confluence:latest
docker run --name confluence --detach --publish 8090:8090 cptactionhank/atlassian-confluence:latest
[/shell]

 Browse to Confluence

To browse to Confluence, we need to know the IP address of our host first. While we're at it, let's confirm that the port was exposed correctly.
[shell linenumbers=false]
machine ip
docker port dev
[/shell]

The IP address will be displayed and we can enter the following in our browser:

http://<ip>:8090

Restart Machine After Reboot

If you reboot your host computer, here's what you have to do to start everything up:
[shell linenumbers=false]
boot2docker start
machine start dev
eval "$(docker-machine env dev)"
[/shell]

Shutdown and Tear Down

If you want to shutdown and complete remove all remnants of the contaner:
[shell linenumbers=false]
docker stop confluence
docker rm confluence
[/shell]
To do the same with the machine:
[shell linenumbers=false]
machine stop
machine rm
[/shell]


Tags:
0 comments