Docker playtime for Dummies

Docker is hot! If you haven’t heard anything about it before you should ask yourself whether you should switch careers. In this blog I will basically explain how to run a Docker container with Drools BRMS (Business Rules Management System) on Microsoft Windows. Yes, that’s right on Windows! I am currently also playing around with the Amazon EC2 Container Service, so perhaps I will explain this in the next blogpost.


Definition:

Docker is an open platform to build, ship and run distributed applications anywhere. Blablabla, let’s play!


1. First install the Docker Toolbox (https://www.docker.com/products/docker-toolbox)

Docker Toolbox contains:

  • Docker Machine for running docker-machine commands
  • Docker Engine for running the docker commands
  • Docker Compose for running the docker-compose commands
  • Kitematic, the Docker GUI
  • A shell preconfigured for a Docker command-line environment
  • Oracle VirtualBox

2. After installation open command prompt and use the following command:

docker-machine ls

This will list all the machine available (none). Using Windows we first need to create a Linux-based machine/host (VM) to be able to fire up Docker containers. Aha, so thats why Oracle Virtualbox is part of the Docker toolkit! Yes, that’s right.

Documentation: https://docs.docker.com/machine/reference/ls/


3. The following command is used to create a Docker-machine (Linux-based machine/host), to spin up a new machine on virtual box, use the following command.

docker-machine create –driver virtualbox docker-machine-01

In the above command, “–driver” flag tells docker machine that we are using the oracle Virtualbox platform. That still makes complete sense.

The Docker-machine will be created using boot2docker as OS, which is a lightweight Linux distribution based on Tiny Core Linux made specifically to run Docker containers. The first time you spin up a new docker machine the iso will be downloaded automatically from github.

So, this command is not creating a container but the underlying VM machine that will host the Docker container.

Documentation: https://docs.docker.com/machine/reference/create/


4. Again use the following command to make sure everything is set!

docker-machine ls

This will list the Docker-machine we just created (docker-machine-01). Our machine is up and running. Under URL, it shows the IP address and the port.

Documentation: https://docs.docker.com/machine/reference/ls/\


5. Use the following command if you want to create a SSH-connection to the Docker-machine. It is not necessary now, but you can if you want!

docker-machine ssh docker-machine-01

This command will create a SSH connection with the docker-machine.

Documentation: https://docs.docker.com/machine/reference/ssh/


6. Next, let’s spin up some containers on our machine. First we need to tell Docker which environment to manage, execute the following command for this:

docker-machine env –shell cmd docker-machine-01

FOR /f “tokens=*” %i IN (‘docker-machine env –shell cmd docker-machine-01’) DO %i

Documentation: https://docs.docker.com/machine/reference/env/


7. Now run the following command to start our first container, in this example we want to start a container for Drools BRMS.

docker run -p 8080:8080 -d –name drools-workbench-showcase jboss/drools-workbench-showcase

Since we fired up a container that corresponded with an actual container-image available on Docker Hub this image is automatically downloaded and used to instantiate the container. How wonderful! You don’t necessarily need to have a Docker Hub account to pull Docker images but if you want to be able to push your preinstalled and configured Docker containers back to Docker Hub you definately need one.

Note that while firing up a container you should take care of the port binding from the Docker-machine host to the Docker container (8080:8080). Port 8080 on the Docker-machine will be redirected to port 8080 on this Docker container.

Documentation: (https://docs.docker.com/engine/reference/run/)


8. Now run the following command to verify that the Docker container is up and running:

docker ps -a

This will list the Docker container we just created (drools-workbench-showcase) including the port bindings etc.


9. Navigate to the Drools workbench to verify everything is up and running:

http://<docker-machine_ip&gt;:8080/drools-wb

Note that the Docker-machine IP can be retrieved using the command at step 4 (docker-machine ls).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: