Subscribe to this blog

Follow by Email

Search This Blog

Pages

Decoding Docker - Part 1

Having worked with multiple Virtualization platforms, I recently got an interesting opportunity to work with its younger sibling containerization . The platform of choice was obviously Docker. Getting Docker up and run in an OS of your preference is a simple task, you can straightaway get it done using the instructionshere. Interesting part is getting to play around with it

Getting it up and running:

Docker can be started as a services or at a tcp port. Starting as a service is pretty straight forward

#service docker start

However, the interesting bit is when you want to run it as a deamon listening to a specific port. This is useful in scenarios when you want to manage the docker engine remotely, say using a windows docker client or using one of the open source GUIs available for docker like Shipyard and Mist.io

Here docker will listen at all IPs of the machine at port 4243. If you want to connect to this docker engine from a remote docker client, the following command can be used

#docker -H tcp://<docker engine host>:4243 <commands>

For eg: #docker -H tcp://<docker engine host>:4243 ps

One downside of this method is that there is no inherent authentication mechanisms for remote access

Spin up your containers:

Lets start with pulling an image from the Docker hub, which is a public repository of Docker images

# docker pull <image name>

Eg: docker pull centos

To list the images in a docker engine, run the following command#docker images

Now lets try running the container, the options given below will run the container in the background#docker run -d -it <image name>

Eg: Docker run -d -it centos

Perfect, this will spin up your container in the docker engine!!

If you want to see the list of containers, you can use the following command

#docker psor # docker ps -aThe first option will list only the running containers , whereas using the -a option will list all containers, including the running and stopped containers

Now that your container is up and running, you might want to take a look into it. You can connect to the shell of the container using the following command

#docker exec -it <container name or id> /bin/bash

Note: The container name/id will be listed while running the "docker ps" commands

After connecting to the shell of the container, you may want to install few softwares in it, set up your applications etc.Once your container is in a desired state, you might want to commit it locally#docker commit <container name> <new-image-name>

A working mom with head in the cloud!! Literally.. I have been working in IT industry for close to 12 years now. Starting with Datacenter management, Virtualization and now cloud computing. Currently, I am working as a Technical Consultant in Microsoft focusing on Cloud and Infra technologies. I enjoy sharing my experiences in my blog, but the opinions expressed in this blog are my own and does not represent those of people, institutions or organizations that I may be associated with in professional or personal capacity, unless explicitly stated.