docker适合初学者吗

by Shahzan

由Shahzan

Whether you are planning to start your career in DevOps, or you are already into it, if you do not have Docker listed on your resume, it’s undoubtedly time for you to think about it, as Docker is one of the critical skill for anyone who is into DevOps arena.

无论您打算开始还是在DevOps中开始职业生涯,如果您的履历中未列出Docker,无疑是您考虑的时候,因为Docker是任何人的一项关键技能进入DevOps领域。

In this post, I will try my best to explain Docker in the simplest way I can.

在本文中,我将尽力以最简单的方式来解释Docker。

Before we take a deep dive and start exploring Docker, let’s take a look at what topics we will be covering as part of this beginner’s guide.

在深入探讨并开始探索Docker之前,让我们看一下作为本入门指南的一部分将涵盖的主题。

  • What is Docker?

    什么是Docker?

  • The problem Docker solves

    Docker解决的问题

  • Advantages and disadvantages of using Docker

    使用Docker的优缺点

  • Core components of Docker

    Docker的核心组件

  • Docker Terminology

    Docker术语

  • What is Docker Hub?

    什么是Docker Hub?

  • Docker Editions

    Docker版本

  • Installing Docker

    安装Docker

  • Some essential Docker commands to get you started

    一些基本的Docker命令可以帮助您入门

  • Wrap-Up

    结语

让我们首先了解一下,什么是Docker? (Let’s begin by understanding, What is Docker?)

In simple terms, Docker is a software platform that simplifies the process of building, running, managing and distributing applications. It does this by virtualizing the operating system of the computer on which it is installed and running.

简而言之,Docker是一个软件平台,可简化构建,运行,管理和分发应用程序的过程。 它通过虚拟化安装和运行它的计算机的操作系统来实现。

The first edition of Docker was released in 2013.

Docker的第一版于2013年发布。

Docker is developed using the GO programming language.

Docker是使用GO编程语言开发的。

Looking at the rich set of functionality Docker has got to offer, it’s been widely accepted by some of the world’s leading organizations and universities, such as Visa, PayPal, Cornell University and Indiana University (just to name a few) to run and manage their applications using Docker.

鉴于Docker提供的丰富功能集,它已被Visa,PayPal,康奈尔大学和印第安纳大学 (仅举几例)等世界领先的组织和大学广泛接受,以运行和管理其使用Docker的应用程序

现在,让我们尝试了解问题所在,以及Docker必须提供的解决方案 (Now let’s try to understand the problem, and the solution Docker has got to offer)

问题 (The Problem)

Let’s say you have three different Python-based applications that you plan to host on a single server (which could either be a physical or a virtual machine).

假设您打算在单个服务器(可以是物理机或虚拟机)上托管三个不同的基于Python的应用程序。

Each of these applications makes use of a different version of Python, as well as the associated libraries and dependencies, differ from one application to another.

这些应用程序中的每一个都使用不同版本的Python,以及相关的库和依赖关系,每个应用程序之间都不相同。

Since we cannot have different versions of Python installed on the same machine, this prevents us from hosting all three applications on the same computer.

由于我们不能在同一台计算机上安装不同版本的Python,因此这使我们无法在同一台计算机上托管所有三个应用程序。

解决方案 (The Solution)

Let’s look at how we could solve this problem without making use of Docker. In such a scenario, we could solve this problem either by having three physical machines, or a single physical machine, which is powerful enough to host and run three virtual machines on it.

让我们看一下如何在不使用Docker的情况下解决此问题。 在这种情况下,我们可以通过拥有三个物理机或一个单一的物理机来解决此问题,该物理机的功能足以在其上托管和运行三个虚拟机。

Both the options would allow us to install different versions of Python on each of these machines, along with their associated dependencies.

这两个选项将使我们能够在这些机器的每台机器上安装不同版本的Python,以及它们相关的依赖项。

Irrespective of which solution we choose, the costs associated with procuring and maintaining the hardware are quite expensive.

无论我们选择哪种解决方案,与采购和维护硬件相关的成本都非常昂贵。

Now, let’s check out how Docker could be an efficient and cost-effective solution to this problem.

现在,让我们看看Docker如何成为解决此问题的有效且具有成本效益的解决方案。

To understand this, we need to take a look at how exactly Docker functions.

为了理解这一点,我们需要看看Docker的功能如何。

The machine on which Docker is installed and running is usually referred to as a Docker Host or Host in simple terms.

安装和运行Docker的机器通常简称为Docker主机或主机。

So, whenever you plan to deploy an application on the host, it would create a logical entity on it to host that application. In Docker terminology, we call this logical entity a Container or Docker Container to be more precise.

因此,无论何时计划在主机上部署应用程序,它都会在其上创建逻辑实体来托管该应用程序。 用Docker术语,更准确地说,我们将此逻辑实体称为容器或Docker容器。

A Docker Container doesn’t have any operating system installed and running on it. But it would have a virtual copy of the process table, network interface(s), and the file system mount point(s). These have been inherited from the operating system of the host on which the container is hosted and running.

Docker容器未安装任何操作系统并在其上运行。 但是它将具有进程表,网络接口和文件系统安装点的虚拟副本。 这些已从托管并运行容器的主机的操作系统继承。

Whereas the kernel of the host’s operating system is shared across all the containers that are running on it.

而主机操作系统的内核是在其上运行的所有容器之间共享的。

This allows each container to be isolated from the other present on the same host. Thus it supports multiple containers with different application requirements and dependencies to run on the same host, as long as they have the same operating system requirements.

这允许将每个容器与同一主机上的另一个容器隔离。 因此,只要它们具有相同的操作系统要求,它就可以支持具有不同应用程序要求和依赖性的多个容器在同一主机上运行。

To understand how Docker has been beneficial in solving this problem, you need to refer to the next section, which discusses the advantages and disadvantages of using Docker.

要了解Docker在解决此问题方面的优势,您需要参考下一部分,该部分讨论了使用Docker的优缺点。

In short, Docker would virtualize the operating system of the host on which it is installed and running, rather than virtualizing the hardware components.

简而言之,Docker将虚拟化安装并运行它的主机的操作系统,而不是虚拟化硬件组件。

使用Docker的优缺点 (The Advantages and Disadvantages of using Docker)

使用Docker的优势 (Advantages of using Docker)

Some of the key benefits of using Docker are listed below:

下面列出了使用Docker的一些关键优势:

  • Docker supports multiple applications with different application requirements and dependencies, to be hosted together on the same host, as long as they have the same operating system requirements.Docker支持具有不同应用程序要求和依赖关系的多个应用程序,只要它们具有相同的操作系统要求,即可将它们托管在同一主机上。
  • Storage Optimized. A large number of applications can be hosted on the same host, as containers are usually few megabytes in size and consume very little disk space.存储优化。 大量应用程序可以托管在同一主机上,因为容器的大小通常只有几兆字节,并且只占用很少的磁盘空间。
  • Robustness. A container does not have an operating system installed on it. Thus, it consumes very little memory in comparison to a virtual machine (which would have a complete operating system installed and running on it). This also reduces the bootup time to just a few seconds, as compared to a couple of minutes required to boot up a virtual machine.坚固性。 容器上没有安装操作系统。 因此,与虚拟机(安装了完整的操作系统并在其上运行)相比,它消耗的内存很少。 与启动虚拟机所需的几分钟相比,这也将启动时间减少到仅几秒钟。
  • Reduces costs. Docker is less demanding when it comes to the hardware required to run it.降低成本。 对于运行它所需的硬件,Docker的要求不高。

使用Docker的缺点 (Disadvantages of using Docker)

  • Applications with different operating system requirements cannot be hosted together on the same Docker Host. For example, let’s say we have 4 different applications, out of which 3 applications require a Linux-based operating system and the other application requires a Windows-based operating system. In such a scenario, the 3 applications that require Linux-based operating system can be hosted on a single Docker Host, whereas the application that requires a Windows-based operating system needs to be hosted on a different Docker Host.具有不同操作系统要求的应用程序不能一起托管在同一Docker主机上。 例如,假设我们有4个不同的应用程序,其中3个应用程序需要基于Linux的操作系统,而另一个应用程序则需要基于Windows的操作系统。 在这种情况下,可以将需要基于Linux的操作系统的3个应用程序托管在单个Docker主机上,而需要将基于Windows的操作系统的应用程序托管在不同的Docker主机上。

Docker的核心组件 (Core Components of Docker)

Docker Engine is one of the core components of Docker. It is responsible for the overall functioning of the Docker platform.

Docker EngineDocker的核心组件之一。 它负责Docker平台的整体功能。

Docker Engine is a client-server based application and consists of 3 main components.

Docker Engine是一个基于客户端-服务器的应用程序,由3个主要组件组成。

  1. Server服务器
  2. REST APIREST API
  3. Client客户

The Server runs a daemon known as dockerd (Docker Daemon), which is nothing but a process. It is responsible for creating and managing Docker Images, Containers, Networks and Volumes on the Docker platform.

服务器运行一个名为dockerd (Docker Daemon)的守护进程 ,它只是一个进程。 它负责在Docker平台上创建和管理Docker映像,容器,网络和卷。

The REST API specifies how the applications can interact with the Server, and instruct it to get their job done.

REST API指定应用程序如何与服务器交互,并指示它完成工作。

The Client is nothing but a command line interface, that allows users to interact with Docker using the commands.

客户端不过是命令行界面,它允许用户使用命令与Docker进行交互。

Docker术语 (Docker Terminology)

Let us take a quick look at some of the terminology associated with Docker.

让我们快速看一下与Docker相关的一些术语。

Docker Images and Docker Containers are the two essential things that you will come across daily while working with Docker.

Docker镜像Docker容器是使用Docker时每天都会遇到的两件事。

In simple terms, a Docker Image is a template that contains the application, and all the dependencies required to run that application on Docker.

简而言之, Docker映像是一个包含应用程序以及在Docker上运行该应用程序所需的所有依赖项的模板。

On the other hand, as stated earlier, a Docker Container is a logical entity. In more precise terms, it is a running instance of the Docker Image.

另一方面,如前所述, Docker容器是一个逻辑实体。 更确切地说,它是Docker Image的运行实例。

什么是Docker Hub? (What is Docker Hub?)

Docker Hub is the official online repository where you could find all the Docker Images that are available for us to use.

Docker Hub是官方的在线存储库,您可以在其中找到所有可供我们使用的Docker映像。

Docker Hub also allows us to store and distribute our custom images as well if we wish to do so. We could also make them either public or private, based on our requirements.

Docker Hub还允许我们存储和分发我们的自定义映像,如果我们愿意的话。 根据我们的要求,我们也可以将它们设为公开或私有。

Please Note: Free users are only allowed to keep one Docker Image as private. If we wish to keep more than one Docker Image as private, we need to subscribe to a paid subscription plan.

请注意:免费用户只能将一个Docker映像保留为私有。 如果我们希望将多个Docker Image保留为私有,我们需要订阅付费订阅计划。

Docker版本 (Docker Editions)

Docker is available in 2 different editions, as listed below:

Docker有2个不同版本,如下所示:

  • Community Edition (CE)

    社区版(CE)

  • Enterprise Edition (EE)

    企业版(EE)

The Community Edition is suitable for individual developers and small teams. It offers limited functionality, in comparison to the Enterprise Edition.

社区版适用于个人开发人员和小型团队。 与企业版相比,它提供的功能有限。

The Enterprise Edition, on the other hand, is suitable for large teams and for using Docker in production environments.

另一方面, 企业版适合大型团队以及在生产环境中使用Docker。

The Enterprise Edition is further categorized into three different editions, as listed below:

企业版进一步分为三个不同的版本,如下所示:

  • Basic Edition

    基本版

  • Standard Edition

    标准版

  • Advanced Edition

    高级版

安装Docker (Installing Docker)

One last thing that we need to know before we go ahead and get our hands dirty with Docker is actually to have Docker installed.

在继续使用Docker之前,我们需要了解的最后一件事实际上是安装Docker。

Below are the links to the official Docker CE installation guides. You can follow these guides to install Docker on your machine, as they are simple and straightforward.

以下是官方Docker CE安装指南的链接。 您可以按照以下指南在您的计算机上安装Docker,因为它们非常简单明了。

  • CentOS Linux

    CentOS Linux

  • Debian Linux

    Debian Linux

  • Fedora Linux

    Fedora Linux

  • Ubuntu Linux

    Ubuntu Linux

  • Microsoft Windows

    微软Windows

  • MacOS

    苹果系统

是否想跳过安装并直接开始练习Docker? (Want to skip installation and head off straight to practicing Docker?)

Just in case you are feeling too lazy to install Docker, or you don’t have enough resources available on your computer, you need not have to worry — here’s the solution to your problem.

万一您因懒惰而无法安装Docker,或者您的计算机上没有足够的可用资源,则不必担心-这是解决问题的方法。

You can head over to Play with Docker, which is an online playground for Docker. It allows users to practice Docker commands immediately, without having to install anything on your machine. The best part is it’s simple to use and available free of cost.

您可以转到Docker的在线游乐场Play with Docker。 它允许用户立即练习Docker命令,而无需在您的机器上安装任何东西。 最好的部分是它易于使用且免费提供。

Docker命令 (Docker Commands)

Now it’s time to get our hands dirty with Docker commands, for which we all have been waiting till now.

现在是时候让我们动手使用Docker命令了,我们大家一直在等待着直到现在。

码头工人创建 (docker create)

The first command which we will be looking at is the docker create command.

我们将要看的第一个命令是docker create命令。

This command allows us to create a new container.

这个命令允许我们创建一个新的容器。

The syntax for this command is as shown below:

该命令的语法如下所示:

docker create [options] IMAGE [commands] [arguments]

Please Note: Anything enclosed within the square brackets is optional. This is applicable to all the commands that you would see on this guide.

请注意:方括号内的任何内容都是可选的。 这适用于您在本指南中看到的所有命令。

Some of the examples of using this command are shown below:

下面显示了使用此命令的一些示例:

$ docker create fedora
02576e880a2ccbb4ce5c51032ea3b3bb8316e5b626861fc87d28627c810af03

In the above example, the docker create command would create a new container using the latest Fedora image.

在上面的示例中,docker create命令将使用最新的Fedora映像创建一个新容器。

Before creating the container, it will check if the latest official image of the Fedora is available on the Docker Host or not. If the latest image isn’t available on the Docker Host, it will then go ahead and download the Fedora image from the Docker Hub before creating the container. If the Fedora image is already present on the Docker Host, it will make use of that image and create the container.

在创建容器之前,它将检查Docker主机上是否有Fedora的最新官方映像。 如果最新映像在Docker主机上不可用,它将继续并在创建容器之前从Docker Hub下载Fedora映像。 如果Docker主机上已经存在Fedora映像,它将使用该映像并创建容器。

If the container was created successfully, Docker will return the container ID. For instance, in the above example 02576e880a2ccbb4ce5c51032ea3b3bb8316e5b626861fc87d28627c810af03 is the container ID returned by Docker.

如果容器创建成功,Docker将返回容器ID。 例如,在以上示例中,02576e880a2ccbb4ce5c51032ea3b3bb8316e5b626861fc87d28627c810af03是Docker返回的容器ID。

Each container has a unique container ID. We refer to the container using its container ID for performing various operations on the container, such as starting, stopping, restarting, and so on.

每个容器都有一个唯一的容器ID。 我们使用容器的容器ID引用容器,以对容器执行各种操作,例如启动,停止,重新启动等。

Now, let us refer to another example of docker create command, which has options and commands being passed to it.

现在,让我们参考docker create命令的另一个示例,该示例具有传递给它的选项和命令。

$ docker create -t -i ubuntu bash
30986b73dc0022dbba81648d9e35e6e866b4356f026e75660460c3474f1ca005

In the above example, the docker create command creates a container using the Ubuntu image (As stated earlier, if the image isn’t available on the Docker Host, it will go ahead and download the latest image from the Docker Hub before creating the container).

在上面的示例中,docker create命令使用Ubuntu镜像创建一个容器(如前所述,如果该镜像在Docker主机上不可用,它将继续并在创建容器之前从Docker Hub下载最新的镜像)。

The options -t and -i instruct Docker to allocate a terminal to the container so that the user can interact with the container. It also instructs Docker to execute the bash command whenever the container is started.

选项-t和-i指示Docker将终端分配给容器,以便用户可以与容器进行交互。 它还指示Docker在容器启动时执行bash命令。

码头工人ps (docker ps)

The next command we will look at is the docker ps command.

我们将要看的下一个命令是docker ps命令。

The docker ps command allows us to view all the containers that are running on the Docker Host.

docker ps命令允许我们查看Docker主机上运行的所有容器。

$ docker ps
CONTAINER ID IMAGE  COMMAND CREATED        STATUS            PORTS NAMES30986b73dc00 ubuntu "bash"  45 minutes ago Up About a minute                 elated_franklin

It only displays the containers that are presently running on the Docker Host.

它仅显示当前在Docker主机上运行的容器。

If you want to view all the containers that were created on this Docker Host, irrespective of their current status, such as whether they are running or exited, then you would need to include the option -a, which in turn would display all the containers that were created on this Docker Host.

如果要查看在此Docker主机上创建的所有容器,而不论它们的当前状态如何(例如它们是否正在运行或退出),则需要包括选项-a,该选项将显示所有容器在此Docker主机上创建的

$ docker ps -a
CONTAINER ID IMAGE  COMMAND     CREATED           STATUS       PORTS NAMES30986b73dc00 ubuntu “bash”      About an hour ago Up 29 minutes elated_franklin02576e880a2c fedora “/bin/bash” About an hour ago Created hungry_sinoussi

Before we proceed further, let’s try to decode and understand the output of the docker ps command.

在继续进行之前,让我们尝试解码并了解docker ps命令的输出。

CONTAINER ID: A unique string consisting of alpha-numeric characters, associated with each container.

容器ID:与每个容器关联的唯一字符串,由字母数字字符组成。

IMAGE: Name of the Docker Image used to create this container.

图像:用于创建此容器的Docker映像的名称。

COMMAND: Any application specific command(s) that needs to be executed when the container is started.

COMMAND:启动容器时需要执行的任何特定于应用程序的命令。

CREATED: This shows the time elapsed since this container has been created.

已创建:显示自创建此容器以来经过的时间。

STATUS: This shows the current status of the container, along with the time elapsed, in its present state.

状态:显示容器的当前状态以及经过的时间,处于其当前状态。

If the container is running, it will display as Up along with the time period elapsed (for example, Up About an hour or Up 3 minutes).

如果容器正在运行,它将显示为“已启动”以及经过的时间段(例如,“已启动”大约一个小时或“已启动” 3分钟)。

If the container is stopped, then it will display as Exited followed by the exit status code within round brackets, along with the time period elapsed (for example, Exited (0) 3 weeks ago or Exited (137) 15 seconds ago, where 0 and 137 are the exit codes).

如果容器已停止,则它将显示为“已退出”,并在圆括号内显示退出状态代码,以及经过的时间段(例如,三周前退出(0)或15秒前退出(137),其中0和137是退出代码)。

PORTS: This displays any port mappings defined for the container.

端口:这将显示为容器定义的所有端口映射。

NAMES: Apart from the CONTAINER ID, each container is also assigned a unique name. We can refer to a container either using its container ID or its unique name. Docker automatically assigns a unique silly name to each container it creates. But if you want to specify your own name to the container, you can do that by including the — — name (double hyphen name) option to the docker create or the docker run (we will look at the docker run command later) command.

名称:除了容器ID外,每个容器还被分配一个唯一的名称。 我们可以使用其容器ID或唯一名称来引用该容器。 Docker会自动为其创建的每个容器分配一个唯一的傻名称。 但是,如果您想为容器指定自己的名称,则可以通过在docker create或docker run(我们将在稍后查看docker run命令)命令中包含— — name (双连字符名称)选项来实现。

I hope this gives you a better understanding of the output of the docker ps command.

我希望这可以使您更好地理解docker ps命令的输出。

码头工人开始 (docker start)

The next command we will look at, is the docker start command.

我们将要看的下一个命令是docker start命令。

This command starts any stopped container(s).

该命令启动所有停止的容器。

The syntax for this command is as shown below:

该命令的语法如下所示:

docker start [options] CONTAINER ID/NAME [CONTAINER ID/NAME…]

We can start a container either by specifying the first few unique characters of its container ID or by specifying its name.

我们可以通过指定容器ID的前几个唯一字符或指定其名称来启动容器。

Some of the examples of using this command are shown below:

下面显示了使用此命令的一些示例:

$ docker start 30986

In the above example, Docker starts the container beginning with the container ID 30986.

在上面的示例中,Docker以容器ID 30986开始启动容器。

$ docker start elated_franklin

Whereas in this example, Docker starts the container named elated_franklin.

而在此示例中,Docker启动了名为elated_franklin的容器。

码头工人停止 (docker stop)

The next command on the list is the docker stop command.

列表上的下一个命令是docker stop命令。

This command stops any running container(s).

此命令停止所有正在运行的容器。

The syntax for this command is as shown below:

该命令的语法如下所示:

docker stop [options] CONTAINER ID/NAME [CONTAINER ID/NAME…]

It is similar to the docker start command.

它类似于docker start命令。

We can stop the container either by specifying the first few unique characters of its container ID or by specifying its name.

我们可以通过指定容器ID的前几个唯一字符或指定其名称来停止容器。

Some of the examples of using this command are shown below:

下面显示了使用此命令的一些示例:

$ docker stop 30986

In the above example, Docker will stop the container beginning with the container ID 30986.

在上面的示例中,Docker将从容器ID 30986开始停止容器。

$ docker stop elated_franklin

Whereas in this example, Docker will stop the container named elated_franklin.

而在此示例中,Docker将停止名为elated_franklin的容器。

docker重启 (docker restart)

The next command we will look at is the docker restart command.

我们将要看的下一个命令是docker restart命令。

This command restarts any running container(s).

此命令重新启动所有正在运行的容器。

The syntax for this command is as shown below:

该命令的语法如下所示:

docker restart [options] CONTAINER ID/NAME [CONTAINER ID/NAME…]

We can restart the container either by specifying the first few unique characters of its container ID or by specifying its name.

我们可以通过指定容器ID的前几个唯一字符或指定其名称来重新启动容器。

Some of the examples of using this command are shown below:

下面显示了一些使用此命令的示例:

$ docker restart 30986

In the above example, Docker will restart the container beginning with the container ID 30986.

在以上示例中,Docker将从容器ID 30986开始重新启动容器。

$ docker restart elated_franklin

Whereas in this example, Docker will restart the container named elated_franklin.

而在此示例中,Docker将重新启动名为elated_franklin的容器。

泊坞窗运行 (docker run)

The next command we will be looking at is the docker run command.

我们将要查看的下一个命令是docker run命令。

This command first creates the container, and then it starts the container. In short, this command is a combination of the docker create and the docker start command.

此命令首先创建容器,然后启动容器。 简而言之,此命令是docker create和docker start命令的组合。

The syntax for this command is as shown below:

该命令的语法如下所示:

docker run [options] IMAGE [commands] [arguments]

It has a syntax similar to that of the docker create command.

它的语法类似于docker create命令的语法。

Some of the examples of using this command are shown below:

下面显示了使用此命令的一些示例:

$ docker run ubuntu
30fa018c72682d78cf168626b5e6138bb3b3ae23015c5ec4bbcc2a088e67520

In the above example, Docker will create the container using the latest Ubuntu image and then immediately start the container.

在上面的示例中,Docker将使用最新的Ubuntu映像创建容器,然后立即启动该容器。

If we execute the above command, it would start the container and immediately stop it — we wouldn’t get any chance to interact with the container at all.

如果执行上述命令,它将启动容器并立即将其停止-我们根本没有任何机会与容器进行交互。

If we want to interact with the container, then we need to specify the options: -it (hyphen followed by i and t) to the docker run command presents us with the terminal, using which we could interact with the container by typing in appropriate commands. Below is an example of the same.

如果要与容器进行交互,则需要指定以下选项:docker run命令的-it(连字符,后跟i和t)向我们展示了终端,使用该终端,我们可以通过键入适当的内容来与容器进行交互命令。 以下是相同的示例。

$ docker run -it ubuntu
root@e4e633428474:/#

In order to come out of the container, you need to type exit in the terminal.

为了从容器中出来,您需要在终端中键入exit。

码头工人 (docker rm)

Moving on to the next command — if we want to delete a container, we use the docker rm command.

继续执行下一个命令-如果要删除容器,请使用docker rm命令。

The syntax for this command is as shown below:

该命令的语法如下所示:

docker rm [options] CONTAINER ID/NAME [CONTAINER ID/NAME...]

Some of the examples of using this command are shown below:

下面显示了使用此命令的一些示例:

$ docker rm 30fa elated_franklin

In the above example, we are instructing Docker to delete 2 containers within a single command. The first container to be deleted is specified using its container ID, and the second container to be deleted is specified using its name.

在上面的示例中,我们指示Docker在单个命令中删除2个容器。 使用其容器ID指定要删除的第一个容器,并使用其名称指定要删除的第二个容器。

Please Note: The containers need to be in a stopped state in order to be deleted.

请注意:容器需要处于停止状态才能删除。

码头工人图像 (docker images)

docker images is the next command on the list.

docker images是列表上的下一个命令。

This command lists out all the Docker Images that are present on your Docker Host.

该命令列出了Docker主机上存在的所有Docker映像。

$ docker images
REPOSITORY  TAG      IMAGE          CREATED        SIZEmysql       latest   7bb2586065cd   38 hours ago   477MBhttpd       latest   5eace252f2f2   38 hours ago   132MBubuntu      16.04    9361ce633ff1   2 weeks ago    118MBubuntu      trusty   390582d83ead   2 weeks ago    188MBfedora      latest   d09302f77cfc   2 weeks ago    275MBubuntu      latest   94e814e2efa8   2 weeks ago    88.9MB

Let us decode the output of the docker images command.

让我们解码docker images命令的输出。

REPOSITORY: This represents the unique name of the Docker Image.

存储库:这表示Docker映像的唯一名称。

TAG: Each image is associated with a unique tag. A tag basically represents a version of the image.

标记:每个图像都与一个唯一的标记关联。 标签基本上代表图像的版本。

A tag is usually represented either using a word or set of numbers or a combination of alphanumeric characters.

标签通常使用单词或数字集或字母数字字符的组合表示。

IMAGE ID: A unique string consisting of alpha-numeric characters, associated with each image.

图像ID:与每个图像关联的唯一字符串,由字母数字字符组成。

CREATED: This shows the time elapsed since this image has been created.

创建:显示自创建该图像以来经过的时间。

SIZE: This shows the size of the image.

尺寸:这显示图像的尺寸。

码头工人rmi (docker rmi)

The next command on the list is the docker rmi command.

列表上的下一个命令是docker rmi命令。

The docker rmi command allows us to remove an image(s) from the Docker Host.

docker rmi命令允许我们从Docker主机中删除映像。

The syntax for this command is as shown below:

该命令的语法如下所示:

docker rmi [options] IMAGE NAME/ID [IMAGE NAME/ID...]

Some of the examples of using this command are shown below:

下面显示了使用此命令的一些示例:

docker rmi mysql

The above command removes the image named mysql from the Docker Host.

上面的命令从Docker主机中删除名为mysql的映像。

docker rmi httpd fedora

The above command removes the images named httpd and fedora from the Docker Host.

上面的命令从Docker主机中删除名为httpd和fedora的映像。

docker rmi 94e81

The above command removes the image starting with the image ID 94e81 from the Docker Host.

上面的命令从Docker主机中删除以映像ID 94e81开头的映像。

docker rmi ubuntu:trusty

The above command removes the image named ubuntu, with the tag trusty from the Docker Host.

上面的命令从Docker主机中删除名称为ubuntu且标签为trusty的映像。

These were some of the basic Docker commands you will see. There are many more Docker commands to explore.

这些是您将看到的一些基本Docker命令。 还有更多的Docker命令可供探索。

结语 (Wrap-Up)

Containerization has recently gotten the attention it deserves, although it has been around for a long time. Some of the top tech companies like Google, Amazon Web Services (AWS), Intel, Tesla, and Juniper Networks have their own custom version of container engines. They heavily rely on them to build, run, manage, and distribute their applications.

尽管容器化已经存在了很长时间,但它最近已经引起了应有的关注。 一些顶级科技公司,例如Google,Amazon Web Services(AWS),Intel,Tesla和Juniper Networks,都有其自己的容器引擎定制版本。 他们严重依赖它们来构建,运行,管理和分发其应用程序。

Docker is an extremely powerful containerization engine, and it has a lot to offer when it comes to building, running, managing and distributing your applications efficiently.

Docker是一个功能非常强大的容器化引擎,在有效地构建,运行,管理和分发应用程序方面,它提供了很多功能。

You have just seen Docker at a very high level. There is a lot more to learn about Docker, such as:

您刚刚看到了非常高级的Docker。 有关Docker的知识还有很多,例如:

  • Docker commands (More powerful commands)Docker命令(功能更强大的命令)
  • Docker Images (Build your own custom images)Docker映像(构建自己的自定义映像)
  • Docker Networking (Setup and configure networking)Docker网络(设置和配置网络)
  • Docker Services (Grouping containers that use the same image)Docker服务(使用相同映像对容器进行分组)
  • Docker Stack (Grouping services required by an application)Docker Stack(应用程序所需的分组服务)
  • Docker Compose (Tool for managing and running multiple containers)Docker Compose(用于管理和运行多个容器的工具)
  • Docker Swarm (Grouping and managing one or more machines on which docker is running)Docker Swarm(对运行docker的一台或多台机器进行分组和管理)
  • And much more…以及更多…

If you have found Docker to be fascinating, and are interested in learning more about it, then I would recommend that you enroll in the courses which are listed below. I found them to be very informative and straight to the point.

如果您发现Docker令人着迷,并且有兴趣学习更多有关它的信息,那么我建议您注册以下课程。 我发现它们非常有用,而且很直接。

If you are an absolute beginner, then I would suggest you enroll in this course, which has been designed for beginners.

如果您是绝对的初学者,那么我建议您参加为初学者设计的本课程 。

If you have some good knowledge about Docker, and are pretty much confident with the basic stuff and want to expand your knowledge, then I would suggest you should enroll into this course, which is aimed more towards advanced topics related to Docker.

如果您对Docker有一定的了解,并且对基础知识非常有信心,并且想扩展您的知识,那么我建议您参加本课程 , 该课程的目的更多是与Docker相关的高级主题。

Docker is a future-proofed skill and is just picking up momentum.

Docker是一项面向未来的技能,并且正在加速发展。

Investing your time and money into learning Docker wouldn’t be something that you would repent.

花时间和金钱来学习Docker不会让您后悔。

Hope you found this post to be informative. feel free to share it across. This really means a lot to me.

希望您发现这篇文章能提供更多信息。 随时分享。 这对我真的很重要。

在说再见之前... (Before you say goodbye…)

Let’s stay in touch, click here to enter your email address (Use this link if the above widget doesn’t show up on your screen).

让我们保持联系, 单击此处输入您的电子邮件地址 (如果上面的窗口小部件未显示在屏幕上,请使用此链接)。

Thank you so much for taking your precious time to read this post.

非常感谢您抽出宝贵的时间阅读这篇文章。

Disclaimer: All product and company names are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any endorsement by them. There may be affiliate links within this post.

免责声明:所有产品和公司名称均为其各自所有者的商标或注册商标。 使用它们并不意味着它们得到任何认可。 这篇文章中可能有会员链接。

翻译自: https://www.freecodecamp.org/news/docker-simplified-96639a35ff36/

docker适合初学者吗

docker适合初学者吗_简化了Docker:面向绝对初学者的动手指南相关推荐

  1. docker没有下载完全_会用Docker的人都别装了,这多简单呐

    学术又官方的说法 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器或Windows 机器上,也可以实现虚拟化,容器是 ...

  2. docker mysql 生产环境_如何部署Docker MySQL生产环境?

    1 前言 Docker容器原则上是短暂的,如果容器被删除或损毁,数据或配置将丢失,所以上个章节部署的MySQL只适合于测试环境,由于生产的需求,本章将使用Docker卷机制持久保存Docker容器中创 ...

  3. docker 删除映像_如何在Docker中删除映像和容器

    docker 删除映像 Docker RMI (Docker rmi) docker rmi removes images by their ID. docker rmi通过其ID删除图像. To r ...

  4. Docker的mysql镜像_详解docker下的Mysql镜像的使用方法

    通常初学者学习docker时,不太清楚怎样拉取一个Mysql镜像并使用,今天这篇文章简单介绍一下使用流程. 一.预习一下用到的docker命令: 1.docker images 列出本地主机上的镜像. ...

  5. 群辉docker安装树莓派镜像_群辉docker安装树莓派镜像_如何在树莓派安装Docker

    文章前言python 由于树莓派是ARM架构的,因此Docker的安装和使用也都有不一样.须要讲的内容比较多,这里单挑出来.linux 树莓派是基于ARM架构的,和PC不一样.因此即便树莓派上能作一些 ...

  6. docker查看现有容器_如何使用Docker将现有应用程序推送到容器中

    docker查看现有容器 by Daniel Newton 丹尼尔·牛顿 如何使用Docker将现有应用程序推送到容器中 (How to shove an existing application i ...

  7. 群辉docker安装树莓派镜像_群晖 Docker 安装 AriaNg+File Browser

    说明: AriaNg 是一个让 aria2 更容易使用的现代 Web 前端,使用响应式布局,支持各种计算机或移动设备.本次所使用的镜像包含 Aria2.AriaNg 和 File Manager 同时 ...

  8. docker 容器共享数据_如何在Docker容器之间共享数据

    docker 容器共享数据 介绍 (Introduction) Docker is a popular containerization tool used to provide software a ...

  9. docker登录密码错误_【WSL+Docker】新手Win10下的WSL Ubuntu18并使用Docker(两种方式)...

    更新于20200711 这段时间微软推出的WSL2似乎很香,后面找个时间试下.目前已经支持GPU和docker,不过目前性能有待提高,还有一些小bug还在完善,喜欢折腾的小伙伴们可以关注下:https ...

最新文章

  1. C++11中enum class的使用
  2. 第四周项目二-太乐了
  3. Python调用HTTP接口并传递cookie
  4. 让浏览器认为现在处于登录状态
  5. 当集合a为空集时a的取值范围_高中数学必修一第一章集合分节练习和章末测试题含答案[1] 2...
  6. 调用另一个cpp的变量_再谈条件变量—从入门到出家
  7. linux suid提权原理,Linux SUID、SGID、sticky提权
  8. java开发遇到最大的问题_java开发遇到的问题总结(三)
  9. “等我干 IT 发财了,就和你离婚”
  10. cx_Oracle安装教程
  11. icon好看的图标-素材库
  12. arcgis 属性表 汇总_最常用的GIS数据汇总
  13. 计算机运行加减乘除哪个最慢,计算机算加减乘除的时间对比
  14. 什么是,泛化能力,过拟合,欠拟合,不收敛,奥卡姆剃刀?
  15. 如何在fragment中添加ListView,并设置ListView中条目的值
  16. 百信计算机管理员登录账号密码,192.168.0.1管理员密码是多少 管理员密码一般是啥...
  17. js一键批量打印_web页面的单页打印以及批量打印实现方法
  18. 【高数复盘】1.6极限存在准则 两个重要极限
  19. 1.31.Flink自定义rocketmq(source/sink)+自定义redis source和sink
  20. 《目标检测蓝皮书》第3篇 卷积神经网络

热门文章

  1. 英文状态下输入字母,字母之间的间隔较大怎么解决?
  2. Xamarin.Forms学习之路——黑猫时钟App
  3. 公司规定所有接口都用 POST请求,这是为什么?
  4. javascript里裁切图片插件库
  5. 简述python语言的主要功能和特点_计算机考试简答题
  6. matlab中在同一图形窗口中绘制出一个周期内的正弦曲线和余弦曲线,多选(3分) 在一个图形窗口同时绘制[0,2π]的正弦曲线、余弦曲线,可以使用命令( )。...
  7. Java - JavaFx之fxml文件的编写及基本使用方式
  8. 计算机英语的词汇量,英语词汇量多少才够用
  9. Photoshop制作WiFi图标
  10. ZUCC 正方教务系统 抢课脚本 抢课流程实现