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.
Downloading Windows installer for boot2docker from GitHub
Run the installer, following the instructions in the “How to Use Docker on Windows ” article and the resource http://docs.docker.com/installation/windows/
Virtual Box is started through its API in the background:
(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:
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.
A simple test can be executed by entering
docker run hello-world
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
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:
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.
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.
This means that whatever is in c:\Users is available inside the Linux VM:
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
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
The tar file is downloaded to c:\Users\lucas_j\Downloads
and is therefore available inside the container
Let’s untar it into our home directory:
tar xzvf Downloads/Downloads/jdk-7u75-linux-x64.tar.gz
And the untarring takes place:
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:
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).
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/
One thought on “My First Steps with Docker – starting from Windows as the Host”
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.
Comments are closed.