Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What can be done with Docker

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what can be done with Docker". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what can be done with Docker.

What is Docker?

Docker is an open platform for program running, testing and delivery. Docker is designed to enable you to deliver applications quickly. In Docker, you can divide your program into different basic parts, each of which can be managed as an application. Docker can help you test quickly, code quickly, deliver quickly, and shorten the cycle from coding to running applications.

Docker uses a lightweight container virtualization platform and combines workflows and tools to help you manage and deploy your applications.

At its core, Docker enables almost any program to run in a secure, isolated container. Security and isolation allow you to run multiple containers on the machine at the same time.

The lightweight nature of the container means that you can get more hardware performance.

The virtualization tools and platforms around the container can help you in the following areas:

Helps you put your application (including the rest of the supporting components) into the Docker container.

Distribute and transfer your containers to other members of your team for further development and testing.

Deploy these applications to your production environment, whether it's a local data center or cloud platform.

What can I do with Docker to deliver your application quickly?

Docker can provide perfect help for your development process. Docker allows developers to develop locally in containers that contain applications and services, which can then be integrated into continuous integration and deployment workflows.

For example, developers write code locally and use Docker to share their development stacks with colleagues. When developers are ready, they can push the code and development stack into the test environment, where they can do all the necessary tests. From the test environment, you can push the Docker image to the server for deployment.

Easier to develop and expand

Docker's container-based platform allows for highly portable work. The Docker container can be run on a developer's machine, on a physical or virtual machine, or on a cloud platform.

The portable and lightweight nature of Docker also makes it easier to manage loads dynamically. You can use Docker to quickly increase the size of applications or shut down applications and services. The speed of Docker means that changes are almost real-time.

Achieve high density and more load

Docker is lightweight and fast, providing a viable and cost-effective alternative to hypervisor-based virtual machines. This is especially useful in high-density environments. For example, building your own cloud platform or PaaS can also get more resource performance in small and medium-sized deployment environments.

What are the main components of Docker

Docker has two main components:

Docker: an open source container virtualization platform.

Docker Hub: a Docker SaaS platform for sharing and managing Docker containers.

What is the architecture of Docker?

Docker uses the client-server (client-server) architecture mode. The Docker client communicates with the Docker daemon. The Docker daemon handles complex and onerous tasks, such as building, running, and publishing your Docker container. The Docker client and the daemon can run on the same system, but you can also use the Docker client to connect to a remote Docker daemon. Docker clients and daemons communicate through socket or RESTful API.

Docker daemon

As shown in the figure above, the Docker daemon is running on a host. Do not interact with the daemon directly, but communicate with it indirectly through the Docker client.

Docker client

The Docker client, which is actually the binary program of docker, is the main way for users to interact with Docker. It receives user instructions and communicates with the Docker daemon behind it, back and forth.

The interior of Docker

To understand the internal construction of Docker, you must know the following three parts:

Docker image (Docker images).

Docker warehouse (Docker registeries).

Docker container (Docker containers).

Docker Mirror

The Docker image is a read-only template. For example, an image can contain a Web application running on Apache and the Ubuntu operating system it uses.

Mirrors are used to create containers. Docker provides a simple way to create a new image or upgrade an existing image, or you can download an image already created by someone else. The Docker image is the construction part of the Docker.

Docker warehouse

The Docker repository is used to hold images. It can be understood as a code repository in code control. Similarly, Docker repositories have both public and private concepts. The name of the public Docker warehouse is Docker Hub. Docker Hub provides a large collection of images for use. These images can be created by yourself, or you can create them based on the images of others. The Docker repository is the distribution part of Docker.

Docker container

Docker containers are very similar to folders. A Docker container contains all the environments that an application needs to run. Each Docker container is created from a Docker image. Docker containers can be run, started, stopped, moved, and deleted. Each Docker container is an independent and secure application platform. The Docker container is the running part of Docker.

How Docker works

So far, we have learned:

We can build a container that holds the application.

We can create a Docker container from the Docker image to run our application.

We can share Docker images through Docker Hub or our own Docker repository.

How Docker mirrors work

As we have seen, the Docker image is a read-only template for the Docker container runtime. Each mirror consists of a series of layers (layers). Docker uses UnionFS to combine these layers into one or two images. The Union file system allows files and folders (called branches) in a separate file system to be transparently overwritten to form a separate, coherent file system.

The original text of this paragraph: We've already seen that Docker images are read-only templates from which Docker containers are launched. Each image consists of a series of layers. Docker makes use of union file systems to combine these layers into a single image. Union file systems allow files and directories of separate file systems, known as branches, to be transparently overlaid, forming a single coherent file system.

Because of the existence of these layers, Docker is so lightweight. When you change a Docker image, such as upgrading to a program to a new version, a new layer is created. So instead of replacing the entire image or re-establishing it (as you might do when using a virtual machine), just a new layer has been added or upgraded. Now you don't have to republish the entire image, you just need to upgrade. Layers make Endeavour Docker mirroring easy and fast.

Each image starts with a basic image, such as ubuntu, a basic Ubuntu image, or fedora, a basic Fedora image. You can use your own image as the basis for a new image, for example, you have a basic image with Apache installed, and you can use it to create your Web application image.

Note: Docker usually obtains the basic image from Docker Hub.

Docker images are created from these basic images through a simple, descriptive step we call instructions. Each instruction creates a new layer in the mirror, and the instruction can contain these actions:

Run a command.

Add files or folders.

Create an environment variable.

Which programs run when the container is run.

These instructions are stored in the Dockerfile file. When you need to create an image, Docker can read these instructions from Dockerfile and run them, and then return a final image.

How does the Docker warehouse work

The Docker repository is the repository for Docker images. You can push your image to your Docker repository.

With the Docker client, you can search for images from the Docker repository.

How Docker containers work

A Docker container contains an operating system, user-added files, and metadata (meta-data). As we can see, each container is built from a mirror. The image tells Docker what the container contains, what program to run when the container starts, and a lot of configuration data. The Docker image is read-only. When Docker runs a container built from the image, it adds a read-write layer at the top of the image where the application can run.

What happens when you run the docker container

Whether you use the docker command or the RESTful API,Docker client, the Docker daemon is told to run a container.

$sudo docker run-I-t ubuntu / bin/bash

Let's analyze this order. The Docker client runs using the docker command, and the run parameter table name client runs a new container. The minimum parameter information that a Docker client needs to tell the Docker daemon to run a container is:

Which image is the container created from? here is ubuntu, the basic Ubuntu image.

The command to run in the container, in this case / bin/bash, runs Bash shell in the container.

So what happens at the bottom after running this command?

In order, Docker does these things:

Pull ubuntu image: Docker checks whether the ubuntu image exists. If it is not available locally, Docker will download it from Docker Hub. If the mirror already exists, Docker uses it to create a new container.

Create a new container: when Docker has this image, Docker will use it to create a new container.

Allocate the file system and mount a read-write layer: the container is created in the file system, and a read-write layer is added to the image.

Assign a network / bridge interface: create a network interface that allows the container to communicate with the local host.

Set an IP address: find an available IP address from the pool and add it to the container.

Run your designated program: run the specified program.

Capture and provide application output: connect and record standard output, input, and errors so that you can see how your program works.

You now have a running container! From here you can manage your container, interact with the application, and after the application is complete, you can stop or delete your container.

Underlying technology

Docker is written in the go language and uses a range of features provided by the Linux kernel to implement the functions we have seen.

Namespace (Namespaces)

Docker takes full advantage of a technology called namespaces to provide an isolated workspace, which we call container (containers). When you run a container, Docker creates a collection of namespaces for the container.

This provides an isolation layer where each application runs in its own namespace and does not access outside the namespace.

Some of the namespaces used by Docker are:

Pid namespace: used in process isolation (PID: Process ID).

Net namespace: used in managing the network interface (NET: Networking).

Ipc namespace: used to manage interprocess communication resources (IPC: InterProcess Communication).

Mnt namespace: used in the administrative mount point (MNT: Mount).

Uts namespace: used in isolating kernel and version identities (UTS: Unix Timesharing System).

Group control

Docker also uses cgroups technology to manage groups. The key to isolating applications is to make them use only the resources you want. This ensures that the containers running on the machine are good multi-tenant citizens. Group control allows Docker to share or restrict the use of hardware resources by containers. For example, restrict the content use of the specified container.

Federated file system

The federated file system (UnionFS) is used to manipulate the creation layers to make them light and fast. Docker uses UnionFS to provide the building blocks of the container. Docker can use many kinds of UnionFS, including AUFS, btrfs, vfs, and DeviceMapper.

Container format

Docker connects these assemblies into a wrapper called a container format (container format). The default container format is libcontainer. Docker also supports traditional Linux containers using LXC. In the future, Docker may support other container formats, such as integration with BSD Jails or Solaris Zone.

Thank you for reading, the above is the content of "what can be done with Docker". After the study of this article, I believe you have a deeper understanding of what you can do with Docker, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report