DockerAn overview of the

Docker is an open platform for developing, delivering, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure just like you manage applications. By taking advantage of Docker’s fast approach to delivering, testing, and deploying code, you can significantly reduce the latency between writing code and running it in production.

DockerWhat can be done?

Deliver your application quickly and consistently

Docker simplifies the development lifecycle by allowing developers to work in a standardized environment using local containers that provide applications and services. Containers are ideal for continuous integration and continuous delivery (CI/CD) workflows.

Scene:

  • Your developers write code locally and share their work with colleagues using the Docker container.
  • They use Docker to push their apps into a test environment and perform automated and manual tests.
  • When developers find bugs, they can fix them in the development environment and redeploy to the test environment for testing and verification.
  • After testing is complete, providing a fix to the customer is as simple as pushing an updated image into production.

Responsive deployment and scaling

Docker is a container-based platform that allows for highly portable workloads. Docker containers can run on developers’ home machines, physical or virtual machines in data centers, on cloud services, or in mixed environments.

Docker’s portability and lightweight features also make it easy for you to accomplish dynamically managed workloads and extend or dismantle applications and services in real time as business needs indicate.

Running more workloads on the same hardware

Docker is light and fast. It provides a viable, cost-effective, and efficient alternative to hyperviser-based virtual machines, so you can leverage more computing power to achieve business goals. Docker is ideal for high-density environments as well as small to medium sized deployments, where you can do more with less resources.

Docker architecture

Docker uses a client-server architecture. Docker clients communicate with the Docker daemon (Deamon), which is responsible for the heavy lifting of building, running, and distributing Docker containers. The Docker client and daemon can run on the same system, or you can connect the Docker client to a remote Docker daemon. Docker clients and daemons communicate using REST apis, UNIX sockets, or network interfaces. Another Docker client is Docker Compose, which allows you to use an application that consists of a set of containers.

Daemons (Docker Daemon)

The Docker daemon (Dockerd) listens to Docker API requests and manages Docker objects, such as images, containers, networks, and volumes. Daemons can also communicate with other daemons to manage Docker services.

The client (Docker client)

Docker client (Docker) is the main way for many Docker users to interact with Docker. When you use commands such as Docker run, the client sends them to Dockerd to execute them. The Docker command uses the Docker API. Docker clients can communicate with multiple daemons.

Warehouse or registry (Docker registries)

The Docker registry is used to store Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured by default to look up images on Docker Hub. You can even run your own private registry.

When you use the Docker pull or Docker run commands, the required images will be extracted from your configured registry. When you use the Docker push command, your image is pushed into the registry that you configured.

Mirror (Docker Images)

An Image is a template used to create a container. Typically, an Image is based on another container, with some additional customizations. For example, you can build an Ubuntu image. You can create your own Image, or you can use images created and published by others. To build an image, you need to use a Dockerfile that defines the steps needed to create and run the image. Each designation in the Dockerfile creates a layer in the Image. When you change the Dockerfile and rebuild the Image, only the layers that have changed are rebuilt. So that’s part of what makes it light and fast compared to other virtualization technologies.

Container (Docker Containers)

A container is a running instance of an image. You can create, start, stop, move, or delete containers using the Docker API or CLI. You can connect a container to one or more networks, add storage to it, and even create a new mirror based on its current turntable.

By default, the container is isolated from the period and its host. You can control how isolated a container’s network, storage, or other underlying subsystems are from other containers or hosts.

The container has an image and any configuration selection provided to it when you re-create or start it. When the container is removed, anything that is not persistent will eventually disappear.

Example docker run command

The following command runs an Ubuntu container, interactively attached to your local command line session, and runs /bin/bash

$ docker run -i -t ubuntu /bin/bash
Copy the code

When you run this command, the following happens (assuming you are using the default registry configuration) :

  1. If you areubuntuThe mirror does not exist locally.DockerWill extract it from the repository you configured, just like youdocker pull ubuntuRun it manually.
  2. DockerWill create a new container, just like youdocker container createRunning the command manually is the same.
  3. DockerAssign a read/write file system to the container as its last layer. This allows a running container to create or modify files and directories in its local file system.
  4. DockerCreate a network interface to connect the container to the default network because you did not specify any network options. This includes assigning to containersIPAddress. By default, a container can connect to an external network using the host’s network connection.
  5. DockerStart the container and execute/bin/bash.because the container runs interactively and is attached to your terminal (because-iand-tFlag), you can use the keyboard to provide input while the output is logged to the terminal.
  6. When you typeexitTo terminate/bin/bashCommand, the container is stopped but not removed. You can restart or delete it.

The underlying technology

Docker is written in the Go programming language and takes advantage of several features of the Linux kernel to provide its functionality. Docker uses a technique called namespaces to provide isolated workspaces. When you run a container, Docker creates a set of namespaces for that container.

These namespaces provide a layer of isolation. Each aspect of the container runs in a separate namespace, and its access is limited to that namespace.