In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The knowledge points of this article include: the introduction of Docker, the role and principle of Docker, the installation and configuration of Docker and the use of Docker. I believe you have a certain understanding of Docker after reading the complete article.
Brief introduction
Docker is an open source container project based on the Goto language. It was born in early 2013 and was initiated by dotCloud. The company later renamed the Docker Inc.Docker project has joined the Linux Foundation and followed the Apache2.0 agreement. The code is hosted at the Github:Docker source address.
All major operating systems now support Docker, and the latest Linux distributions RedHat, CentOS and Ubuntu all have Docker packages by default.
The idea of Docker is to achieve "Build,Ship and Run Any App, Anywhere", that is, to achieve "once package, run everywhere" at the application component level by managing the application's life cycle of Packaging, Distribution, Deployment and Runtime. The application components here can be a Web application, a compiler environment, a set of database platform services, or even an operating system or cluster.
Based on a number of open source technologies on the Linux platform, Docker provides efficient, agile and lightweight container solutions and supports deployment to local environments and multiple mainstream cloud platforms. It can be said that Docker provides a "one-stop" practical solution for the development, operation and deployment of applications for the first time.
The early Docker code implementation is based on LXC (Linux Containers, that is, Linux container). Since version 0.9, Docker has developed the libcontainer project as a broader container-driven implementation.
In a nutshell, the reader can understand the Docker container as a lightweight sandboxie (sandbox). There is an application running in each container, different containers are isolated from each other, and containers can communicate with each other through the network. The creation and stopping of containers is very fast, almost the same as the creation and termination of native applications; in addition, the additional requirements of the container itself for system resources are also very limited, much lower than traditional virtual machines. In many cases, there is nothing wrong with even treating the container directly as an application.
A new way to create distributed applications Rapid distribution and deployment through containers to package applications, decouple applications and run platforms for faster delivery and deployment, start fast, start and stop can be achieved in tricks, saving a lot of time in development, testing, deployment and more efficient use of resources. Thousands of Docker containers can be run on one host. Running Docker does not require the support of additional virtualization managers (virtual machine manager, and Hypervisor). Docker is kernel-level virtualization that enables more advanced performance and easier migration and scaling, and Docker containers can run on almost any platform Including physical machine, virtual machine
Simpler update management for virtual machines, public clouds, private clouds, personal computers, servers, etc. With Dockerfile, tedious updates can be achieved with only small configuration modifications, and work efficiency can be improved. The standardized process Docker makes it easy for users to obtain, distribute and update application images, storage reuse, incremental update Docker and traditional virtual machines through operations similar to the design concept of Git.
Principle
Docker runs basic commands and modes:
Docker Engine:
Docker architecture:
Docker and Virtualization
Virtualization technology is a general concept, which has different understandings in different areas. In the computing domain, it generally refers to computing virtualization (computingvirtualization), or server virtualization. The definition on Wikipedia is as follows:
"in computing technology, virtualization is a kind of resource management technology, which abstracts and transforms various physical sources of computing, such as servers, networks, memory, and storage, to break down the uncut barriers between physical structures. so that users can use these resources in a better way than the original state."
It can be seen that the core of virtualization is the abstraction of resources, and the goal is to run multiple systems on the same host at the same time
Unified or applied, so as to improve the utilization of system resources, and bring the benefits of cost reduction, convenient management, fault tolerance and disaster tolerance.
The differences between Docker and common virtual machines:
Installation
Users can visit the Get Docker Docker official page of the official website of Docker to see how to obtain Docker, as well as the types of platforms supported by Docker. Currently, Docker supports Docker piloting, Docker Hub, Docker Cloud and other services.
Docker engine: including support for installing Docker on desktop or cloud platforms, and providing simple security for enterprises
Flexible container cluster orchestration and management; DockerHub: officially provided cloud hosting service, which can provide public or private image repositories; DockerCloud: officially provided container cloud service, which can complete container deployment and management, and can be supported completely
Holding capacity project, as well as CI, CD functions.
Linux installation
$sudo apt-get update$sudo apt-get install docker-ce docker-ce-cli containerd.io
Mac installation
$brew cask install docker
Or:
Download and install manually: Docker Mac portal
Run:
Start the Docker service after the installation is complete, and then try to run the following name:
Docker run-d-p 80:80-name webserver_test nginx# then visit in the browser: http://127.0.0.1 to see the effect, a nginx server has been built, isn't it delicious Docker has three core concepts: Image (image), container (Container), Repository (image), image (Image)
Mirroring is the most important of the three core concepts of Docker and is the basis for creating Docker containers. In essence, it is a file. Through version management and incremental file system, Docker provides a very simple mechanism to create and update existing images. Users can even download an application image from the Internet and use it directly.
The corresponding image needs to exist locally before Docker runs the container. If the image does not exist, Docker will try to download it from the default image repository (default uses the repository in the Docker Hub public registration server). Users can also use custom image repositories through configuration.
The command $docker pull NAME [: TAG] $docker pull ubuntu:18.04 is equivalent to docker pull registry.hub.docker.com/ubuntu:18.04. If you download from an unofficial repository, you need to specify the full repository address NAME: image warehouse name TAG: image tag before the repository name. If you do not specify the default value of latest, the latest version of the image in the repository will be downloaded.
Note:
In general, the latest tag of the image means that the content of the image will track changes in the latest version, and the content is unstable. Therefore, in terms of stability, do not ignore the mirrored label information or use the default latest tagged image in the production environment.
View image information and view the list of images on the local host: $docker images or $docker image ls# parameter >-- digests=true | false: list the digital summary value of the image. Default is No; >-f,-- filter= []: filter the listed images, for example, dangling=true displays only those images that are not in use; you can also specify images with specific annotations, etc. >-- format= "TEMPLATE": controls the output format, such as .ID for ID information, .Repository for warehouse information, etc. >-Q,-- quiet=true | false: only output ID information, default is No more subcommands option can also be viewed through man docker-images
The display is as shown in the figure:
REPOSITORY: from which repository TAG: tag information of the image IMAGE ID: ID of the image, where the same ID can be a different TAG, and the complete ID consists of 64 hexadecimal characters. By default, the first 12 bits CREATED: creation time of the image SIZE: image size. Excellent images are often relatively small, and the image size information only indicates the logical size of the image. In fact, since only one copy of the same mirror layer is stored locally, the storage space physically occupied will be less than the sum of the logical volumes of each mirror and add the image label.
To facilitate the use of specific images in subsequent work, you can also use the docker tag command to add a new label to any local image. For example, add a new myubuntu: latest image tag:
$docker tag ubuntu:latest myubuntu:latest to view image details
Use the docker inspect command to get the details of the image, including the producer, adaptive architecture, digital summary of each layer, and so on:
The above code of $docker inspect ubuntu:18.04# returns a message in JSON format. If we only need one of the items, we can use-f to specify. For example, get the ContainerConfig:$docker inspect-f {{".ContainerConfig"}} ubuntu:18.04 of the image and use the history command to view the image history.
Since the image file consists of multiple layers, how do you know what the contents of each layer are? At this point, you can use the create subcommand, which lists the creation information for each layer.
Search for image $docker search nginx parameter:-f,-- filter filter: filter output-- format string: format output-- limit int: number of images displayed. Default 25--no-trunc: no truncation of output result $docker search-- filter=is-official=true nginx delete and clean the image
Use the dockerrmi or docker image rm command to delete the image in the format dockerrmi IMAGE [IMAGE...], where IMAGE can be a label or ID.
The $docker rmi myubuntu:latest parameter:-f,-force: forces the image to be deleted, even if a container depends on it;-no-prune: do not clean up the untagged parent image. Note: when the same image has multiple tags, the docker rmi command only deletes the specified tags in multiple tags of the image, and does not affect the image file # delete all images $docker rmi $(docker ps-a) # use it with caution!
After using Docker for a period of time, some temporary image files and some unused images may be left in the system, which can be cleaned by the docker image prune command.
Create a mirror
There are three main ways to create an image:
Create a basic thousand local template based on an existing image container import create based on Dockerfile (more commonly used) create an image using Dockerfile
Dockerfile is a configuration file in text format, and users can use Dockerfile to quickly create custom images. Consists of one line of command statements and supports comment lines that begin with #. Generally speaking, the main body of Dockerfile is divided into four parts:
Basic mirror information maintainer information mirror operation instruction container executes instructions when it starts
After reading the above, do you have any further understanding of Docker containers? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.