Docker 简明教程
Docker - Installation
让我们了解一下各个产品的安装。
Let’s go through the installation of each product.
Docker for Windows
下载安装程序后,双击它来启动安装程序,然后按照下面给出的步骤进行操作。
Once the installer has been downloaded, double-click it to start the installer and then follow the steps given below.
Step 1 − 单击协议条款,然后单击“安装”按钮继续进行安装。
Step 1 − Click on the Agreement terms and then the Install button to proceed ahead with the installation.
Step 2 − 完成后,单击“完成”按钮完成安装。
Step 2 − Once complete, click the Finish button to complete the installation.
Docker ToolBox
下载安装程序后,双击它来启动安装程序,然后按照下面给出的步骤进行操作。
Once the installer has been downloaded, double-click it to start the installer and then follow the steps given below.
Step 1 − 在开始屏幕上单击“下一步”按钮。
Step 1 − Click the Next button on the start screen.
Step 2 − 在下一个屏幕上保留默认位置并单击“下一步”按钮。
Step 2 − Keep the default location on the next screen and click the Next button.
Step 3 − 保留默认组件并单击“下一步”按钮继续。
Step 3 − Keep the default components and click the Next button to proceed.
Step 4 − 保留“其他任务”原样,然后单击“下一步”按钮。
Step 4 − Keep the Additional Tasks as they are and then click the Next button.
Step 5 − 在最终屏幕上,单击“安装”按钮。
Step 5 − On the final screen, click the Install button.
Working with Docker Toolbox
现在我们来看一下如何在 Windows 上使用 Docker Toolbox 处理 Docker 容器。第一步是启动 Docker Toolbox 应用程序,在安装 Docker 工具箱时,会在桌面上创建该应用程序的快捷方式。
Let’s now look at how Docker Toolbox can be used to work with Docker containers on Windows. The first step is to launch the Docker Toolbox application for which the shortcut is created on the desktop when the installation of Docker toolbox is carried out.
接下来,启动 Docker 工具箱时,您将看到正在进行配置。
Next, you will see the configuration being carried out when Docker toolbox is launched.
完成后,您将看到 Docker 已配置并启动。您将获取一个 Docker 交互式外壳。
Once done, you will see Docker configured and launched. You will get an interactive shell for Docker.
为了测试 Docker 是否正常运行,我们可以使用 Docker run command 下载并运行一个简单的 HelloWorld Docker container 。
To test that Docker runs properly, we can use the Docker run command to download and run a simple HelloWorld Docker container.
Docker run command 的工作原理如下 −
The working of the Docker run command is given below −
docker run
此命令用于在 Docker 容器中运行命令。
This command is used to run a command in a Docker container.
Example
sudo docker run hello-world
此命令将下载 hello-world 映像(如果当前不存在),并将 hello-world 作为容器运行。
This command will download the hello-world image, if it is not already present, and run the hello-world as a container.
Output
当我们运行上述命令时,我们将获得以下结果-
When we run the above command, we will get the following result −
如果您想在 Windows 上运行 Ubuntu OS,可以使用以下命令下载 Ubuntu 映像 −
If you want to run the Ubuntu OS on Windows, you can download the Ubuntu Image using the following command −
Docker run –it ubuntu bash
此处,您通过 –it 选项告诉 Docker 以交互方式运行命令。
Here you are telling Docker to run the command in the interactive mode via the –it option.
在输出中,您可以看到 Ubuntu 映像已下载并运行,然后您将以 root 用户身份登录 Ubuntu 容器。
In the output you can see that the Ubuntu image is downloaded and run and then you will be logged in as a root user in the Ubuntu container.