Tech Skills Development

What is Docker: Quick Applications Development with Containers

Docker is a platform that enables quick application development through Containers. Using containers, developers can package up an application with all its dependencies and ship it out as one package.

The objective of this blog post is to give you a full overview of what Docker is, its components, how it works, and more.

 

What is Docker?

 

What is Docker?

Docker is a platform that enables quick application development through containers. Using containers, developers can package up an application with all its dependencies and ship it out as one package. This makes deploying and managing applications much more accessible, especially in a cloud-based or microservices-based architecture.

Containers are standardised units containing all dependencies and environments to develop and run a given application. Containers are a lightweight, stand-alone, executable package that includes everything needed to run a piece of software, including code, runtime, system tools, system libraries, and settings.

You can learn more about Docker on QA. For complete beginners, QA has an introductory course, Introduction to Docker.

Docker Architecture

Docker is built on a client-server model. The Docker client communicates with the Docker daemon, which is in charge of building, running, and distributing your Docker containers. A Docker client and daemon can run on the same system, or a Docker client can connect to a remote Docker daemon. The Docker client and daemon communicate via a REST API, UNIX sockets, or a network interface. Docker Compose is another Docker client that allows you to work with applications made up of a collection of containers.

Docker Architecture

The Docker architecture consists of these main components:

  • Docker Client
  • Docker Daemon
  • Docker Registries
  • Docker Desktop
  • Docker Objects:
    • Docker Images
    • Docker Containers

Docker Client

The Docker client is a tool that allows users to interact with Docker servers. It provides a command-line interface (CLI) that can be used to issue commands to the server, as well as a graphical user interface (GUI) that can be used to manage Docker servers. The Docker client talks to the Docker daemon, sending it the commands to build, run, and stop containers. The Docker client and daemon can run on the same system or connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate via sockets or through a RESTful API.

Docker Daemon

The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and data volumes. A single Docker daemon can manage multiple containers and images. When you install Docker, a dockerd daemon is automatically configured and launched.

Docker Registries

A registry is a collection of repositories, and a repository is a collection of images. Docker Hub is a public registry that contains many Docker images. You can also run your own private registry.

Docker Desktop

Docker Desktop is an application for macOS and Windows machines to create and manage Docker containers. With Docker Desktop, you can develop and test your applications locally, then deploy them to production with confidence. Docker Desktop includes everything you need to build, test, and ship your applications.

Docker Desktop is the easiest way to run Docker on your desktop. If you’re new to Docker, you can start with the Docker Basics course. Docker Desktop is free to download and use.

Docker Images

Images are read-only templates used to create Docker containers. Images are created with the build command and can be pushed to a registry with the push command. The Docker Hub maintains a collection of official images, and you can browse the Docker Hub to find your needed images.

Docker Containers

A container is a runtime instance of a Docker image—what the image becomes in memory when executed. It runs completely isolated from the host environment by default, only accessing host files and ports if configured.

Docker Networks

Networks are used to enable communication between containers. By default, containers can communicate with each other by their container ID. You can also create user-defined networks.

How Docker Works

How Docker works is very simple. When you install Docker, it creates a virtual environment on your computer. This virtual environment is completely isolated from your main operating system (OS), making it very secure.

Docker containers can hold any application. When you want to run a container, you tell Docker which image you want to use and what command you want to run. Docker will then fetch the image and run the command inside the isolated environment.

Docker images are built from instructions called Dockerfiles. A Dockerfile is just a text file containing a list of commands that must be run to build the image. For example, an image could be built from a Dockerfile that installs Apache and copies over some static HTML files.

When you run a command in a Docker container, the output of that command is displayed on your screen. But, the changes made to the files inside the container are not saved when the container is stopped. You must create a new image from the container to save the changes.

Creating a new image from a container is called committing. To commit a container, you use the docker commit command. This command takes the container ID and a name for the new image. For example, if you wanted to save the changes made to a container with the ID of 1234 as a new image called “my-image”, you would run the following command:

 

$ docker commit 1234 my-image

 

Once you have achieved a new image, you can push it to a Docker registry so that others can use it. Docker registries are websites where images can be stored and shared. The largest and most popular registry is Docker Hub.

 

To run a Docker container, you first must pull the image from the registry. For example, if you wanted to run the "my-image" image that you pushed to Docker Hub, you would use the following command:

 

$ docker run my-image

 

This would start a new container from the "my-image" image and run it on your computer.

 

Docker Pricing

Docker pricing is based on the repository size, the number of users, and the level of support required. Four payment plans are offered, including a free community edition and a paid enterprise edition:

  • Docker Personal: A free edition of Docker comes bundled with unlimited repositories and 200 image pulls every 6 hours.
  • Docker Pro: Priced at 5 USD per month. Bundled with 5000 image pulls a day with up to 5 concurrent builds.
  • Docker Team: Priced at 9 USD per user per month, with a minimum of 5 users.
  • Docker Business: Priced at 24 USD per user per month, with a minimum of 5 users.

Below is a table comparing what the packages offer:

 

 

 

Personal Pro Team Business
0 USD 5 USD/Month 9 USD/User/Month 24 USD/User/Month
Docker Desktop
Unlimited public repositories
Unlimited Scoped tokens
Docker engine + Kubernetes
= = =
200 image pulls / 6 hours 5000 image pulls / day Unlimited image pulls Unlimited image pulls
/ 5 concurrent builds 15 concurrent builds 15 concurrent builds
/ / Can add users in bulk Can add users in bulk
/ / Audit Logs Audit Logs
/ / / Single Sign-on
/ / / Purchase via invoice
/ / / Volume pricing available

 

 

 

Docker Advantages and Disadvantages

There are multiple reasons to use Docker. Docker enables developers to package applications with all the dependencies needed and ship them out as self-contained units. This way, you can run the same application on different machines without worrying about different environments causing issues.

Docker also makes it easy to set up development environments quickly. You can use a pre-built image from Docker Hub or create your own and have a complete environment up and running in minutes.

There are also several security benefits to using Docker. By running each application in its own isolated container, you can limit each access to the underlying host system. This can help to prevent one compromised container from giving an attacker access to the rest of the system.

The main reason not to use Docker is that it can add complexity to your development workflow. If you are working on a team of developers, you must ensure that everyone uses the same version of Docker and that your application containers are compatible.

There are many reasons why someone might choose to start using Docker. Some common reasons include wanting to increase the efficiency of their development workflow, creating a more consistent development environment, or reducing the time and effort required to set up and maintain a development environment.

Docker Use Cases

Docker has multiple use cases, as follows:

  1. Development and Testing:

    • Quick Setup: Easily spin up development and testing environments, ensuring that they are consistent across different machines and setups.
    • Isolation: Test applications in isolated environments to prevent conflicts and ensure accurate results.
  2. Deployment:

    • Application Shipping: Package applications and their dependencies into Docker images, which can then be deployed to production environments in containers.
    • Consistency: Ensure that applications run the same way in production as they did during development.
  3. Microservices:

    • Architecture: Develop and deploy microservices-based applications, where each microservice runs in its own container, facilitating easier management and scaling.
  4. Orchestration:

    • Container Management: Use Docker Swarm or Kubernetes to orchestrate and manage large numbers of containers, handling tasks such as scaling, load balancing, and automated deployments.

Docker vs Virtual Machines

Docker and Virtual Machines (VMs) differ in many aspects, such as architecture, security, etc.

Learn Docker on QA's platform

Here’s a full list of training content on Docker that you can find in the QA Library:

We hope this blog post helped you understand Docker’s multiple aspects and features. 

Thanks and Happy Learning!

 

Related Articles