Docker - Take Two - Starting From Windows with Linux VM as Docker Host docker image

Docker – Take Two – Starting From Windows with Linux VM as Docker Host

My first attempt with Docker was from my Windows host machine using boot2docker, as described in this article: https://technology.amis.nl/2015/03/15/my-first-steps-with-docker-starting-from-windows-as-the-host/. Boot2docker is a great tool for being able to work with Docker on a Windows machine. However, I ran into limitations – such as not being able to create containers with the GUI applications running in them. Besides, Linux seems to be – for now at least – the more natural environment for Docker. So decided to create a Linux VM – actually a Virtual Box VM – that would serve as my Docker host.

In this article I will walk through the steps I went through in order to get this Linux VM running on my Windows host and subsequently turn that VM into the Docker Server in which one or more containers will be running – eventually to serve as demo and training environments, for example with Oracle Databases and Middleware. After all, Mark Nelson showed the way in this wonderful article: https://redstack.wordpress.com/2014/11/14/gettingn-to-know-docker-a-better-way-to-do-virtualization/.

I decided to closely follow Mark’s lead in his choice of Linux VM: Ubunty 14.04.1, to be created using Vagrant (about which I have blogged before – for example https://technology.amis.nl/2014/06/26/provisioning-an-oracle-11g-database-virtualbox-vm-with-vagrant-and-puppet-for-dummies/ ).

 

Stage One – Create Ubuntu VM using Vagrant

I have both Vagrant and Virtual Box set up on my laptop. From that starting point, I open a command line window and create directory into which to create the Vagrant configuration for the VM.

SNAGHTML65c24fe

I initialize the Vagrant configuration.

image

Next, I open the vagrant file that gets  created in a text editor, to make some changes:

SNAGHTML65d6eca

I have indicated that the GUI should be used, that the memory should be increased over the initial setting and that a local folder ../temp (which resolves to c:\temp on the Windows host) should be mapped to the folder/host/temp in the Linux VM.

After making these changes and saving the file, the VM can be created using vagrant:

image

It will take some time to download the base box (janihur’s ubuntu-1404-desktop box).

Once downloading is complete, the VM is booted:

image

and before too long, my Ubuntu 14.04.1 VM is running with its beautiful desktop and all:

SNAGHTML660390b

It turns out on my first attempt that the curl utility is no yet available. I have to go through two steps to get it to work (on the command line, as sudo):

sudo apt-get update

and:

sudo apt-get install curl

image

Once that is taken care of, I can go on to install docker

 

Stage Two – Install Docker into the VM

 

Using the instructions from Mark Nelson, it is not hard to get going:

curl -sSL https://get.docker.com/ubuntu | /bin/sh

image

This will download the apt registry keys for Docker and install the Docker program.

Test the successful installation:

image

 

Thanks to http://www.tekhead.org/blog/2014/09/installing-docker-on-ubuntu-quick-fix/ I could resolve an issue with this message “ Error loading docker apparmor profile: fork/exec /sbin/apparmor_parser: no such file or directory ()” that appeared when I tried to start Docker using “docker -d”

sudo apt-get install apparmor

image

After making this fix, I can run the Docker daemon that other sessions can subsequently connect to:

image

Another error message: whenever I try to do anything with Docker, I run into “permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?“ When I perform actions as sudo, I do not have these issues. Also see: http://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo. The user I am using is to be added as a member of the docker group.

image

Now user vagrant can actually start interacting with Docker:

image

And start a new container:

image

 

After some time, the download is complete and the container is created, started, the ls is executed and the container is brought down again:

image

So next when we inspect the set of Docker images, the one we downloaded is listed:

image

Stage Three – Create a Container (and an Image) with Java and Oracle WebLogic

Subsequently, I follow Mark’s instructions with regard to creating a group, a user and downloading the X libraries we need:

image

 

As per Mark’s instructions, I exit the container and create an image out of it.

I have downloaded the JDK 1.7.75 to my Windows host and copied into the folder that is to be shared with the VM that runs the Docker Server:

SNAGHTML70dbcfc

I then start the container again, specifying how the folder /host_temp/Downloads on the VM is to mapped to the folder /home/oracle/Downloads in the container:

docker run -ti -v /host_temp/Downloads:/home/oracle/Downloads b30988747324 /bin/bash

and:

image

Next, I install the JDK in the container:

 

image

Exit the container, list the containers, commit the container – to create an image from the current container state – and tag the image with a useful title and version label: oracle-base:1.0

image

Next, start a new container based on this latest image and share the host’s X display with a container:

docker run -ti -p 0.0.0.0:7001:7001 -v /tmp/.X11-unix:/tmp/.X11-unix -v /host_temp/Downloads:/home/oracle/Downloads -e DISPLAY=$DISPLAY oracle-base:1.0 /bin/bash

image

With the X display shared, we can run GUI applications inside the container, such as shown here for jconsole:

image

and tadada:

image

Note: this was my big issue with running Docker through boot2docker.

I have downloaded WebLogic 12.1.3 generic installer from OTN:

image

and copied the file to the folder that is shared with the VM.

image

Now I want to install the WebLogic Server into a container based on oracle-base:1.0.

image

The installer runs, the checks fail but skip the warnings:

image

Next the wizard appears. Go through the steps, accept defaults:

image

 

imageimage

The configuration wizard will start subsequently, used for creating a WebLogic Domain.

image

Again, by and large default settings:

image

image

When the wizard is done, you can start the WebLogic Server base_domain using

/home/oracle/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/startWebLogic.sh

SNAGHTML71a3fd2

When the server is running, you can access the Administration Console in the browser in the host VM:

image

Time to create an image for the container, now that it contains WebLogic 12.1.3. Exit the container, list all containers and commit the one we just extended:

docker commit -a “vagrant” -m  “WebLogic 12.1.3 Installed and base_domain created” dfe855989747

image

List the images, tag the one that was just created: docker tag ed49b759dc09 oracle-wls12_1_3:1.0

and for good measure, run another container, based on this new image:

docker run -ti -p 0.0.0.0:7001:7001 -v /tmp/.X11-unix:/tmp/.X11-unix -v /host_temp/Downloads:/home/oracle/Downloads -e DISPLAY=$DISPLAY oracle-wls12_1_3:1.0  /bin/bash

Use the same statement as before to run the base_domain:

/home/oracle/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/startWebLogic.sh

The next figure visualizes the current situation – with Windows, the Ubuntu Virtual Box that hosts the Docker engine and the Docker container that hosts WebLogic 12.1.3:

docker-image

Just out of curiosity I checked the size of the Virtual Box image. After creating several images, apparently the size of the VM on physical hard disk is 3 GB. I am curious how this will grow when I start adding containers.

image

4 Comments

  1. Edward Orlowski May 1, 2015
    • Edward Orlowski May 4, 2015
  2. Torsten Kleiber March 30, 2015
    • Lucas Jellema April 1, 2015