What is the docker ecosystem?

青灯夜游
Release: 2022-06-06 14:26:19
Original
2944 people have browsed it

The ecosystem includes: 1. Docker Hub, which is an official resource for pre-written Dockerfiles and provides public and private image repositories; 2. Docker Engine, the core software used to run and manage containers; 3 , Kitematic, is a visual management tool; 4. Machine and Swarm, provide a simple set of tools for various virtualization and cloud service providers to move and scale their local projects; 5. Compose; 6. Cloud ; 7. Center.

What is the docker ecosystem?

The operating environment of this tutorial: linux5.9.8 system, docker-1.13.1 version, Dell G3 computer.

Docker is a tool for creating "containers" that contain only what you need for an independent application or technology stack. Unlike virtual machines, these containers share the same resources to manage the interaction between the container and the host. This makes Docker containers fast, lightweight, secure, and shareable.

The currently available Docker ecosystem includes: Docker Hub, Docker Engine, Kitematic, Docker Machine, Swarm, Docker Compose, Dokcer Cloud and Data Center. The functions of these tools will be introduced in detail below. , and how these tools can be better combined.

Docker Hub

The core of any project using Docker is a Dockerfile file. This file contains instructions for how Docker creates an image. Let's look at a simple example:

FROM python:2.7
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
Copy after login

In this example, the Dockerfile pulls a specific version of the existing image, copies the current local directory into the container's file system, sets it as the working directory, and then uses the pip command Download Python dependencies from a text file.

Docker Hub is an official resource for pre-written Dockerfiles, providing public (free) and private (paid) image repositories. If you're looking for a Dockerfile to meet your needs, start by searching on Docker Hub and use the project documentation, downloads, and image ratings to help guide your decision.

What is the docker ecosystem?

Docker Engine

Docker Engine is used to run and manage containers core software. Often people refer to it simply as Docker or the Docker Platform. The Docker engine consists of many specialized tools working together to create and run containers, such as APIs, execution drivers, runtimes, shims, etc.

Docker Engine creates Dockerfile files and converts them into usable containers. Docker Engine is the core of Docker. Without Docker Engine, nothing can run. There are several ways to download Docker Engine depending on your operating system. You can Discover more details here .

To start a container based on an image in Docker Hub, you should first pull the image and run it. Continuing with the Python example:

docker pull python
docker run -it --rm --name script-name -v "$PWD":/usr/src/appname -w /usr/src/appname python:3 python app.py
Copy after login

This will pull the latest Python image and then open a container to run a Python script and exit the container after running. The run command provides more option settings, you can Read the complete guide here .

When a Docker run command starts to become more complex, it may be a better idea to create your own custom Dockerfile. Start a container based on a local Dockerfile and run the following directory containing the files:

docker build -t my_image .
Copy after login

This command will create an image named my_image. Run the following command to start a container based on this image:

docker run -name my_image_container -i -t my_image
Copy after login

This command will open a container based on the custom my_image image. This container is named my_image_container.

Kitematic (Docker visual management tool)

对于那些宁愿避免命令行的用户来说,  Kitematic  是一个 Docker GUI 工具,它可以更快速、更简单的运行Docker容器,现在已经支持 Mac /Windows/Linux。

搜索你需要的镜像,创建一个容器,你最好去Kitematic。Kitematic提供了基本的配置选项,但对于更高级的设置,你可能需要进入命令行。   

What is the docker ecosystem?

你的容器出现在左手边,在那里它们可以被启动、停止、重启,更有用的是,你可以在那里找到容器日志和直接SSH(exec按键)访问。   

What is the docker ecosystem?

Docker Machine和Swarm

生产中使用Docker的第一步是了解  Machine  和Swarm,它们为各种虚拟化和云服务提供商提供了一套简单的工具集用以移动和缩放他们的本地项目。  

“生产中使用Docker的第一步是了解Machine和Swarm。”  

例如,在Azure上创建一个Docker实例:  

docker-machine create -d azure --azure-subscription-id="XXX" --azure-subscription-cert="/mycert.pem" ecodemo
Copy after login

这个命令使用预装的Docker创建一个Ubuntu 12.04-based虚拟机并命名为ecodemo。每个供应商都需要不同的参数和认证方法,这些默认设置可以被重写。在  这个文档  中可以阅读到更多的细节。   

当与  Swarm  结合后,Machine可以创建Docker实例的集群,这个集群被视为一个单一的、大的Docker实例。每一个Swarm集群都需要一个master实例,这个master实例可以用下面的命令来创建:  

docker-machine create
-d virtualbox
--swarm
--swarm-master
--swarm-discovery token://TOKEN_ID
swarm-master
Copy after login

这样就会在VirtualBox中创建一个Docker实例并且设置这个Docker实例为Swarm集群的一个master节点。TOKEN_ID非常重要,因为它可以帮助集群中的所有节点识别彼此。除了手动创建TOKEN_ID标识以外,Swarm也有  发现系统  来帮助你管理这个过程。 

下面的命令使用相同的TOKEN_ID标识添加Docker实例到Swarm集群:  

docker-machine create
-d virtualbox
--swarm
--swarm-discovery token://TOKEN_ID
swarm-node-n
Copy after login

swarm-node-n对于集群中的每一个节点来说都是一个唯一的名字。   

现在,代替从单个虚拟机中开启容器,你可以在集群中开启容器,master节点将会把这个容器分配给最可用的和最有能力的节点。 

Docker Compose

Compose  使得由多个组件(像容器)组成的应用程序更加简单,你可以开始使用一个命令在一个单一的配置文件中声明所有这些组件。   

下面是一个Compose文件(称为docker-compose.yml)的例子,这个例子创建三个  Crate  数据库实例和一个  Laravel  (用一些额外的配置)PHP框架实例。最重要的是,容器与Links配置选项相连。  

crate1:
image: crate
ports:
- "4200:4200"
- "4300:4300"
crate2:
image: crate
crate3:
image: crate
volumes:
- ./data:/importdata
laravelcomposer:
image: dylanlindgren/docker-laravel-composer
volumes:
- /laravel-application:/var/www
command: --working-dir=/var/www install
links:
- crate1
laravelartisan:
image: dylanlindgren/docker-laravel-artisan
links:
- crate1
volumes_from:
- laravelcomposer
working_dir: /var/www
command: serve --host=0.0.0.0:8080
ports:
- "8000:8000"
- "8080:8080"
Copy after login

所有这些实例和它们的配置现在可以通过运行以下在同一目录中的docker-compose.yml文件的命令来开始:  

docker-compose up
Copy after login

What is the docker ecosystem?

你可以使用相同的子命令作为Docker的命令来影响所有以docker-compose开始的容器。例如,docker-compose stop命令可以停止以docker-compose开始的容器。   

What is the docker ecosystem?

Docker Cloud

容器的自动化管理和编排是Docker的主要功能,但却一直由第三方服务来提供,直到去年Docker获得了  Tutum(它支撑着Docker云)  。虽然没有完整的命令行工具(还没有),Docker云服务允许Docker Compose文件设置应用程序栈,所以它不是来自于生态型的其它部分的一个大的导流。  

“容器的自动化管理是Docker的重要组成,但知道最近一直由第三方来提供。”  

例如:  

crate1:
image: crate
ports:
- "4200:4200"
- "4300:4300"
command: crate -Des.network.publish_host=_ethwe:ipv4_
crate2:
image: crate
command: crate -Des.network.publish_host=_ethwe:ipv4_
crate3:
image: crate
command: crate -Des.network.publish_host=_ethwe:ipv4_
Copy after login

这样就创建了同一个镜像的三个实例,其中一个手动设置主机与Docker之间的端口分配,其他的端口分配是自动的。我将很快重新访问command。   

如果你想在超过一个节点(节点能够运行它可以管理的足够多的容器和一个私有仓库上扩展应用程序,Docker Cloud是有偿服务。这对于实验目的来说足够了。记住,Docker Cloud默认管理托管在第三方托管服务器上的容器,所以你也需要支付费用。使得Docker Cloud代理运行在任何你管理的Linux主机上是可能的,你可以  在这里找到操作指南  。   

What is the docker ecosystem?

上面的截图显示了三个使用预先设定的规则运行在跨越两个数字海洋的实例上的Docker容器,这个预先设定的规则是根据你设置的参数来将容器分配给主机。它会自动确保你指定数量的容器始终在运行。   

在之前的Docker Compose例子中,你可能已经注意到_ethwe:ipv4_。这是Docker Cloud的另外一个重要特征。许多分布式应用和服务依赖“  服务发现  ”来找到同一服务的其他实例并进行通信。当在数据中心和物理机器上传播服务时,这往往需要实例的手动说明或者需要另一种方式来找到彼此。   

Docker Cloud包括支持  Weave  在你的实际网络中创建一个“软”网络;所有的容器和应用都可以发现彼此,无论它们被托管在哪里。在上面的例子中,我们重写了向容器发出的默认命令,以确保它接收它需要使用此功能的信息。  

Data Center

到目前为止,本文涉及的大部分工具都是你安装,主机,和支持的工具。对企业用户来说,他们寻找安全性、性能和支持较高的保证,Docker提供了  数据中心  。   

它使用了覆盖这里的许多相同的工具包,但是增加了一个放置你的镜像的私有仓库,一个私有云,高级支持,和供应商可能吸引企业用户的第三方集成。这些包括LDAP and Active Directory用户管理,容器检测,和日志记录。  

推荐学习:《docker视频教程

The above is the detailed content of What is the docker ecosystem?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template