Docker Overview

Reading Time: 3 minutes

What is Docker?

Docker is an open platform for developing, shipping, and running applications. It is one of the popular tools to build Continuous Integration and Delivery pipelines. Each organization has its own way of building DevOps solution depending on their needs. 21 DevOps and Docker Reference Architectures pulled together the design decisions of some organizations. I highly recommend it to see the different pipelines.

What can I use Docker for?

  • Fast, consistent delivery of your applications throughout the software delivery life cycle.
  • Providing fast feedback on the quality and deployability of the system is available to everyone on the team, and people make acting on this feedback their highest priority
  • Responsive deployment and scaling
  • Running more workloads on the same hardware

Docker architecture

Related image

Client

The Docker client is set of commands, which Docker users interact with Docker, such as  docker buildand docker run. Please see the official page or my post about commands. Commands are executed by Docker deamon for image and container operations, such as building and running, as well as accessing images stored in docker registry, such as pulling and pushing.

Image

An image is a lightweight, stand-alone, executable package that includes everything needed to run a piece of software. It is the base for creating containers. Consider it as a class in Object Oriented Programming terms.

Image                                         Container

An image is usually based on a base image. For example, you may create front-end and back-end microservices as Docker images separately for a full stack web application. Frontend image can be be based on the nginximage. Backend image may be based on the alpine image, with some additional installs, such as the Tomcat web server and Maven for your Java application. There is also an option to create an image from scratch.

An image is created with a Dockerfile, a script that is composed of various instructions. A sample Dockerfile is as follows:

FROM openjdk:8-jre-alpine
ADD target/backend.jar app.jar 
EXPOSE 8090 
ENV JAVA_OPTS="" 
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]

Container

container is a runtime instance of an image. If an image is a class, then a container is an instance of a class. A container is defined by its image as well as any configuration options you provide to it when you create or run it. For instance, docker run -p 9000:80 -t angular-webpack command creates and then starts a container over the specified image (angular-webpack), which we built in advance.

Registry

A Docker registry stores Docker images. Docker provides two registries: Docker Hub for free-to-use and Docker Trusted Registry for commercial usage. I am using Docker Hub for my current side projects. Users can pull and push images using docker pulland docker push commands.

Docker vs Virtual Machines

  • Containers take up less space than VMs (container images are typically tens of MBs in size), and start almost instantly
  • Each VM includes a full copy of an operating system, one or more apps, necessary binaries and libraries – taking up tens of GBs. VMs can also be slow to boot.
  • Integration with other DevOps tools (e.g.:Github, Jenkins) is easy.
CONTAINERS
CONTAINERS
VIRTUAL MACHINES
VIRTUAL MACHINES

 

References

1. https://www.docker.com/what-container

2. https://docs.docker.com/engine/docker-overview/

3. https://puppet.com/resources/whitepaper/state-of-devops-report

4. https://www.edureka.co/blog/what-is-docker-container

5. http://www.imotif.net/index.php/2016/10/14/docker-swarm/

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *