≡ Menu

Docker

Docker is changing – scratch that – Docker has changed the way applications are built, deployed and run. If you are completely new to Docker, I recommend reading my other post: What is Docker? An absolute beginner’s guide. There, in addition to explaining what Docker is, I walk you through how to create a docker container and run your application in it. In this post, let’s take a step further by creating a distributed service using Docker. In other words, let’s make Docker production-ready. You’ll learn the following

  1. What is docker-compose and how to create your first docker-compose.yml ?
  2. What is a docker swarm and how it provides a robust, scalable container platform ?
  3. How to create a docker swarm and deploy your application in it ?
  4. A working example along the way – end-to-end.

Sounds good ? Let’s jump.

swarm

Read More

What is Docker? An absolute beginner’s guide

To the uninitiated, we are not talking about Docker clothing company, which makes the popular Men’s Khakis. What we are talking about is the Docker that has changed the way Software Applications are built, shipped and run. You have probably heard about Docker and how cool it is, but never really understood fully. And you are itching to finally sit down and read about it. You have come to the right place. In this blog post, I’m going to demystify Docker for you.  By reading this guide fully, you will understand,

  1. What the heck is Docker?
  2. What makes Docker so invaluable and indispensable?
  3. How to install Docker on your PC or MAC?
  4. How to build images and run containers
  5. How to create and use Data volumes with Docker
  6. How to configure basic Networking

Ready? Let’s begin.

Docker image

What the heck is Docker?

Docker is a platform for Applications to be built and run in a container with all the required software packaged in it. 

But you ask, what in the world is container?

Container is a Docker process that can be run on any Linux or Windows based system. It includes everything it needs to run, including System libraries, application code, application dependencies and configuration files. (You throw Docker container at a Car’s bumper and it will still work. Just kidding.). A Docker container is a mini-machine in its own right. Containers running on a system share the Operating System Kernel with other processes (including other Docker containers).

Tip: You can list all the Docker containers running your system by running the command

docker ps

Let’s take a look at the diagram below, which shows how various components fit it.

docker-container

To contrast this with how software applications are traditionally run, look at the image below.

docker-container-1

At this point, you may be wondering, ‘Wait a minute. I’ve seen this before. Are you not talking about virtualization? Vmware and stuff?

Not really. Simply put, vmware visualizes the underlying hardware resources. But Docker visualizes the Operating System.

docker-container-vm.png

At this point, if you have been doing Application Support for a while, one striking advantage should be obvious to you: consistency of environments. Think about how many times you have been told by the development team: ‘Oh, but it works in my local Dev environment. Something must be wrong in production servers. May be a jar file is missing in the classpath in Prod?, Or may be the Java minor version is different in prod?’ Painful. Docker puts an end to all this environment specific mysteries.

So, to summarize: Docker is a container solution that enables building, shipping and running applications with all the required software in a single unit. The benefits include consistency across deployments, fast startup, flexible and developer-friendly build process.

Enough fluff. Let’s get our hands moving by actually running a Docker container.

Read More

How to install Docker on Linux?

Are your ready to taste the awesome power of Docker? I hope you are. Because once you get your feet wet in Docker, you will be unstoppable :-). In this blog post, I want to quickly show you how you can install Docker on RedHat Enterprise Linux. The procedure should be similar in other flavors.

  1. First, login as root into your system. If you don’t have root access, you should at least have sudo access to root.
  2. Create a docker repository file as follows
    • Use your favorite text editor to create a file named /etc/yum.repos.d/docker.repo
    • Add the following contents
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

Read More