My First Steps with Docker – starting from Windows as the Host

1
Share this on .. Tweet about this on TwitterShare on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

After reading quite a bit about Docker – especially the great write up by Mark Nelson (Getting to know Docker – a better way to do virtualization?) I believe it is more than about time for me to delve a little further into Docker. Following Edwin Biemond’s lead, I have dabbled quite a bit in Vagrant and Puppet and had quite satisfying results. The attraction of Docker – the even leaner way of dealing with various virtual environments – is enough to try to get acquainted at least a little. The idea would be that with Docker, the containers I run – based on images I define – do not actually each require their own Virtual Machine -with all associated overhead. Additionally, one image can extend from another – so one base Linux image can be extended to become Linux+Oracle Database which can be extended to become Linux+Oracle Database + a special demo or training set up. All that comes later – first I want to get a simple example running on my Windows 7 laptop.

Steps:

Downloading Windows installer for boot2docker from GitHub

image

Run the installer, following the instructions in the “How to Use Docker on Windows ” article and the resource http://docs.docker.com/installation/windows/

 

imageSNAGHTML174e814

SNAGHTML17511d2

SNAGHTML17541c7

 

 

Run Boot2Docker

image

 

SNAGHTML189100e

Virtual Box is started through its API in the background:

SNAGHTML18b5b8f

(Boot2Docker creates a Linux VM that acts as the Docker Server – because Windows cannot be a native Docker server right now).

The logging for the VM gives some indication as to what Boot2Docker is taking care of:

SNAGHTML18c744c

Then, when the VM is created, boot2docker connects to it. Boot2docker is the client through which we can interact with the Docker Server that manages images and containers.

SNAGHTML18d4448

A simple test can be executed by entering

docker run hello-world

SNAGHTML18da377

This downloads a Docker Image and creates a Container based on that Image. The output shown in the screenshot indicates that the container was created, started and accessed correctly.

 

Start up an empty Ubuntu 14.04 container:

docker run ubuntu:14.04 ls

image

Again, the image is downloaded, a container is created and fired up and the ls command is executed in the container.

At this point, I start working my way through the Mark Nelson article – which explains things wonderfully well.

 

Stopping and Starting the boot2docker client

On the Windows Command Line, type “boot2docker stop” to quit a boot2docker session. This will power down the VM that was created. Using “boot2docker start” will start the client again by starting up the VM again:

image

In this case, the VM is started, but the command line interface is not available. With “boot2docker ssh” I can now get into the client.

image

Mapping between Windows Host File System and Docker Container

The boot2docker VM has a predefined folder mapping between Windows (folder c:\users) and the VM’s file system: c\Users.

SNAGHTML20cbc47

This means that whatever is in c:\Users is available inside the Linux VM:

image

Because we can also map from the Docker host into the container, we can make files on the Windows file system available inside Docker containers.

By starting the container using Docker with the following instruction, we map the local folder /c/Users/lucas_j (which itself is a mount on the Docker host of the Windows host folder c:\Users\lucas_j) to the folder /home/oracle/Downloads in the container. Anything we download on the Windows host can be used within the container.

docker run -ti -v /c/Users/lucas_j:/home/oracle/Downloads d6122c9300ee /bin/bash

SNAGHTML2140d91

 

Installing the JDK into the container

For example installing the JDK into the container is done as follows:

Download the TAR from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

image

The tar file is downloaded to c:\Users\lucas_j\Downloads

image

and is therefore available inside the container

image

 

Let’s untar it into our home directory:

cd

tar xzvf Downloads/Downloads/jdk-7u75-linux-x64.tar.gz

image

And the untarring takes place:

image

After exiting the container, we can create a new image for the container and tag the image so it is easier to recognize and reference:

image

 

At this point, even though I am impressed with what I am seeing, I do have a challenge: in some of the containers I am going to create and run, I will want to use a GUI. However, I have not found a way through boot2docker to have a graphical display, an X-terminal, in the container. It seems that the DockerGUI tool (http://dockerstop.com/) offers that option – and I like to look into it sometime. For now however, I will continue with the creation of a Linux Virtual Machine, installer Docker into that VM and start dockerizing from within the VM, rather than from my Windows operating system. More news on these experiences to follow.

(if there is an easy way of adding GUI support to the boot2docker VM, that would also be an option – but I do not know how to do that).

 

Resources

How to Use Docker on Windows  – http://blog.tutum.co/2014/11/05/how-to-use-docker-on-windows – very useful tips on sharing files between Windows and the Boot2Docker VM and username & password details

Download boot2docker for Windows – https://github.com/boot2docker/windows-installer 

Handy Docker Tips and Examples – http://flurdy.com/docs/docker/docker_osx_ubuntu.html

DockerGUI – http://dockerstop.com/

Share this on .. Tweet about this on TwitterShare on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press books: Oracle SOA Suite 11g Handbook and Oracle SOA Suite 12c Handbook. Frequent presenter on community events and conferences such as JavaOne, Oracle Code and Oracle OpenWorld.

1 Comment

  1. I am running boot2docker in a corporate environment. Boot2docker is unable to access the image download url from the company intranet and it ends with the below error –

    x509: certificate signed by unknown authority.

    I have the company certificates with me but I don’t know where should these certificates be configured in VM so that boot2docker will see it and reach to https url to download image. Can you please suggest.

Leave a Reply