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 are the characteristics of Docker

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is to share with you about the characteristics of Docker. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Docker is an open source engine that automatically deploys development applications to containers. It was written by the Docker team and licensed under the Apache 2.0 open source agreement. It provides a simple, lightweight modeling method, makes the development life cycle more efficient and faster, and encourages service-oriented architecture design. The goal of the Docker project is to implement a lightweight operating system virtualization solution. Docker is based on technologies such as Linux container (LXC). Docker is further encapsulated on the basis of LXC, so that users do not need to care about the management of the container, making the operation easier. Users can manipulate Docker containers as easily as a fast and lightweight virtual machine.

Characteristics of Docker:

Faster delivery and deployment

More efficient virtualization

Easier migration and expansion

Easier management

Performance comparison between Container Technology and traditional Virtual Machine

Comparison between Docker and Virtual Machine Construction

The Docker container is essentially a process on the host. Docker realizes resource isolation through namespace, resource restriction through cgroups, and efficient file operation through write-time copy mechanism (copy-on-write).

Docker has five namespaces: process, network, mount, host and shared memory. In order to isolate problematic applications, Docker uses Namespace to isolate processes, create isolated running spaces for processes or process groups, and provide different views of namespaces for processes. Thus, each isolated process group is externally represented as a container (container). It is important to note that Docker makes users think that they occupy all the resources, but this is not a "virtual machine".

Three concepts in Docker: image, container, warehouse

Image: a Docker image is a read-only template that can be used to create a Docker container. Docker provides a simple mechanism to create or update an existing image, and users can even download an image from someone else to use it directly.

Mirroring is a file structure. Each command in Dockerfile creates a new hierarchy in the file system on which the file system is built, and the image is built on top of these federated file systems. The official Docker website has a dedicated page to store all available images at index.docker.io.

Container (Container): a container is a running instance created from an image. It can be started, started, stopped, and deleted. Each container is an isolated and secure platform. Think of the container as a simple version of the Linux environment, and Docker uses the container to run applications. The image is read-only, and the container creates a writable layer as the top layer at startup.

Warehouse: a warehouse is a place where images are stored centrally. Multiple repositories are often stored on the warehouse registration server (Registry), and each warehouse contains multiple images, each with a different tag. At present, the largest public repository is Docker Hub, which stores a large number of images for users to download.

The Docker repository is used to store our images, and after we have created our own image, we can use the push command to upload it to a public or private warehouse, so that the next time we want to use this image on another machine, we just need to pull it from the warehouse. The concept of a Docker repository is similar to that of Git, and the registration server can be understood as a managed service such as GitHub.

one。 Install Docker

Prerequisites:

Running Docker requires a high level of kernel, so it is generally recommended to run directly on a platform like Ubuntu. But as a container standard, Docker also supports other platforms such as CentOS, Mac OS X, Windows and so on. Currently, Docker supports the following versions of CentOS:

CentOS 7 (64 bit)

CentOS 6.5 (64-bit) and beyond

Kernel versions > = 2.6.32-431 are required when running CentOS 6.5 and later, because these kernels contain specific modifications to run Docker.

Docker uses AUFS as the storage driver by default, but AUFS is not included in the mainline kernel of Linux. Device Mapper can be used as a storage driver in CentOS, a new feature introduced in the 2.6.9 kernel version. We need to confirm that this feature is enabled first:

CentOS 7

The Docker RPM package is already included in the CentOS-Extra repository, so we can install it directly using Yum:

# yum install docker

CentOS 6.6

It is important to note that there is already an executable system package with the same name docker in CentOS6.6. So the Docker RPM package is named docker-io, and we uninstall docker first.

# yum-y remove docker

Step 3 Install Docker-IO

# yum-y install docker-io

This completes the installation of Docker.

# / etc/init.d/docker start # start docker

# docker info # View the basic information of docker

two。 Docker basic operation # docker run-d-- name mynginx nginx # starts nginx image, does not automatically pull# docker stop bfd094233f96 # stop a container, delete according to container id # docker rm bfd094233f96 # delete a container # docker attach d20f3dc6cd92 # enter a running container

The-t option lets Docker assign a pseudo terminal (pseudo-tty) and bind it to the standard input of the container

-I keeps the standard input of the container open.

-name uses a custom name

This command is not easy to use. It is recommended to use the following command to enter the container:

[root@localhost docker] docker inspect-- format "{{.State.Pid}}" mynginx # get container pid 19769 [root@localhost docker] nsenter-- target 19769-- mount-- uts-- ipc-- net-- pid # enter the container (recommended method) docker run-d-p 91:80-- name mynginx2 nginx #-p specified port mapping, mapping 80 to 91 of host

Storage Mirror:

# docker save-o ubuntu_14.04.tar ubuntu:14.04

Load the image:

# docker load < ubuntu_14.04.tar or use # cat ubuntu.tar | docker import-test/ubuntu:v1.0

Remove the local mirror:

# docker rmi training/sinatra

Clean up all untagged local images:

# docker rmi $(docker images-Q-f "dangling=true")

Where-Q and-f are abbreviations for quiet,-filter, and the complete command can actually be written as follows, isn't it easier to understand?

# docker rmi $(docker images-quiet-filter "dangling=true")

Note: whether the container will run for a long time is related to the command specified by docker run and has nothing to do with the-d parameter.

To get the output of the container, you can use the docker logs command.

# docker logs [container ID or NAMES]

Delete the container:

# docker rm does not delete running containers by default

Underlying information about containers and images:

# docker inspect container/image

You can view:

IP address of the container instance

Port binding list

Search for specific port mappings

Collect configuration details

Copy the file from within the container to the specified path:

# docker cp container:path hostpath

Use Dockerfile to build the image:

# docker build [options] PATH | URL

-rm=true indicates that all intermediate containers are removed after the construction is successful

-no-cache=false indicates that caching is not used during the build process

Thank you for reading! This is the end of this article on "what are the characteristics of Docker?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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