赞
踩
debian docker
Docker is an application that simplifies the process of managing application processes in containers. Containers let you run your applications in resource-isolated processes. They’re similar to virtual machines, but containers are more portable, more resource-friendly, and more dependent on the host operating system.
Docker是一种应用程序,可简化容器中管理应用程序流程的过程。 容器使您可以在资源隔离的进程中运行应用程序。 它们类似于虚拟机,但是容器更可移植,更资源友好并且更依赖于主机操作系统。
For a detailed introduction to the different components of a Docker container, check out The Docker Ecosystem: An Introduction to Common Components.
有关Docker容器的不同组件的详细介绍,请查看Docker生态系统:通用组件简介 。
In this tutorial, you’ll install and use Docker Community Edition (CE) on Debian 10. You’ll install Docker itself, work with containers and images, and push an image to a Docker Repository.
在本教程中,您将在Debian 10上安装并使用Docker Community Edition(CE)。您将安装Docker本身,使用容器和映像,并将映像推送到Docker Repository。
To follow this tutorial, you will need the following:
要遵循本教程,您将需要以下内容:
One Debian 10 server set up by following the Debian 10 initial server setup guide, including a sudo non-root user and a firewall.
按照Debian 10初始服务器设置指南设置一台Debian 10服务器,包括sudo非root用户和防火墙。
An account on Docker Hub if you wish to create your own images and push them to Docker Hub, as shown in Steps 7 and 8.
如果要创建自己的映像并将其推送到Docker Hub,请在Docker Hub上创建一个帐户,如步骤7和8所示。
The Docker installation package available in the official Debian repository may not be the latest version. To ensure we get the latest version, we’ll install Docker from the official Docker repository. To do that, we’ll add a new package source, add the GPG key from Docker to ensure the downloads are valid, and then install the package.
官方Debian存储库中提供的Docker安装软件包可能不是最新版本。 为确保获得最新版本,我们将从官方Docker存储库中安装Docker。 为此,我们将添加一个新的软件包源,从Docker添加GPG密钥以确保下载有效,然后安装该软件包。
First, update your existing list of packages:
首先,更新您现有的软件包列表:
Next, install a few prerequisite packages which let apt
use packages over HTTPS:
接下来安装这让一些必备软件包apt
使用的包装通过HTTPS:
Then add the GPG key for the official Docker repository to your system:
然后将官方Docker存储库的GPG密钥添加到您的系统中:
Add the Docker repository to APT sources:
将Docker存储库添加到APT源:
Next, update the package database with the Docker packages from the newly added repo:
接下来,使用新添加的存储库中的Docker软件包更新软件包数据库:
Make sure you are about to install from the Docker repo instead of the default Debian repo:
确保要从Docker存储库而不是默认Debian存储库进行安装:
You’ll see output like this, although the version number for Docker may be different:
您将看到这样的输出,尽管Docker的版本号可能不同:
- ocker-ce:
- Installed: (none)
- Candidate: 5:18.09.7~3-0~debian-buster
- Version table:
- 5:18.09.7~3-0~debian-buster 500
- 500 https://download.docker.com/linux/debian buster/stable amd64 Packages
Notice that docker-ce
is not installed, but the candidate for installation is from the Docker repository for Debian 10 (buster
).
请注意,未安装docker-ce
,但安装的候选人来自Debian 10( buster
)的Docker存储库。
Finally, install Docker:
最后,安装Docker:
Docker is now installed, the daemon started, and the process enabled to start on boot. Check that it’s running:
现在已安装Docker,启动了守护程序,并启用了启动过程。 检查它是否正在运行:
The output will be similar to the following, showing that the service is active and running:
输出将类似于以下内容,显示该服务处于活动状态并且正在运行:
-
-
-
-
- Output
-
- ● docker.service - Docker Application Container Engine
- Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
- Active: active (running) since Mon 2019-07-08 15:11:19 UTC; 58s ago
- Docs: https://docs.docker.com
- Main PID: 5709 (dockerd)
- Tasks: 8
- Memory: 31.6M
- CGroup: /system.slice/docker.service
- └─5709 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Installing Docker gives you not just the Docker service (daemon) but also the docker
command line utility, or the Docker client. We’ll explore how to use the docker
command later in this tutorial.
安装Docker不仅可以为您提供Docker服务(守护程序),还可以为您提供docker
命令行实用程序或Docker客户端。 在本教程的后面,我们将探讨如何使用docker
命令。
By default, the docker
command can only be run the root user or by a user in the docker group, which is automatically created during Docker’s installation process. If you attempt to run the docker
command without prefixing it with sudo
or without being in the docker group, you’ll get an output like this:
默认情况下,只能以root用户或由docker组中的用户运行docker
命令,而docker组是在Docker安装过程中自动创建的。 如果您尝试运行docker
命令而不以sudo
作为前缀或不在docker组中,则将获得以下输出:
-
-
-
-
- Output
-
- docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
- See 'docker run --help'.
If you want to avoid typing sudo
whenever you run the docker
command, add your username to the docker
group:
如果要避免在每次运行docker
命令时键入sudo
,请将用户名添加到docker
组:
To apply the new group membership, log out of the server and back in, or type the following:
要应用新的组成员身份,请注销服务器并重新登录,或键入以下命令:
You will be prompted to enter your user’s password to continue.
系统将提示您输入用户密码以继续。
Confirm that your user is now added to the docker group by typing:
通过输入以下命令确认您的用户已添加到docker组:
-
-
-
-
- Output
-
- sammy sudo docker
If you need to add a user to the docker
group that you’re not logged in as, declare that username explicitly using:
如果需要将用户以未登录的身份添加到docker
组中,请使用以下命令明确声明该用户名:
sudo usermod -aG docker username
sudo usermod -aG码头用户名
The rest of this article assumes you are running the docker
command as a user in the docker group. If you choose not to, please prepend the commands with sudo
.
本文的其余部分假设您以docker组中的用户身份运行docker
命令。 如果您选择不这样做,请在命令前加上sudo
。
Let’s explore the docker
command next.
接下来让我们探索docker
命令。
Using docker
consists of passing it a chain of options and commands followed by arguments. The syntax takes this form:
使用docker
包括向其传递一系列选项和命令,后跟参数。 语法采用以下形式:
To view all available subcommands, type:
要查看所有可用的子命令,请键入:
As of Docker 18, the complete list of available subcommands includes:
从Docker 18开始,可用子命令的完整列表包括:
-
-
-
-
- Output
-
- attach Attach local standard input, output, and error streams to a running container
- build Build an image from a Dockerfile
- commit Create a new image from a container's changes
- cp Copy files/folders between a container and the local filesystem
- create Create a new container
- diff Inspect changes to files or directories on a container's filesystem
- events Get real time events from the server
- exec Run a command in a running container
- export Export a container's filesystem as a tar archive
- history Show the history of an image
- images List images
- import Import the contents from a tarball to create a filesystem image
- info Display system-wide information
- inspect Return low-level information on Docker objects
- kill Kill one or more running containers
- load Load an image from a tar archive or STDIN
- login Log in to a Docker registry
- logout Log out from a Docker registry
- logs Fetch the logs of a container
- pause Pause all processes within one or more containers
- port List port mappings or a specific mapping for the container
- ps List containers
- pull Pull an image or a repository from a registry
- push Push an image or a repository to a registry
- rename Rename a container
- restart Restart one or more containers
- rm Remove one or more containers
- rmi Remove one or more images
- run Run a command in a new container
- save Save one or more images to a tar archive (streamed to STDOUT by default)
- search Search the Docker Hub for images
- start Start one or more stopped containers
- stats Display a live stream of container(s) resource usage statistics
- stop Stop one or more running containers
- tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
- top Display the running processes of a container
- unpause Unpause all processes within one or more containers
- update Update configuration of one or more containers
- version Show the Docker version information
- wait Block until one or more containers stop, then print their exit codes

To view the options available to a specific command, type:
要查看特定命令可用的选项,请键入:
docker docker-subcommand --help
docker docker-subcommand-帮助
To view system-wide information about Docker, use:
要查看有关Docker的系统范围信息,请使用:
Let’s explore some of these commands. We’ll start by working with images.
让我们探索其中一些命令。 我们将从处理图像开始。
Docker containers are built from Docker images. By default, Docker pulls these images from Docker Hub, a Docker registry managed by Docker, the company behind the Docker project. Anyone can host their Docker images on Docker Hub, so most applications and Linux distributions you’ll need will have images hosted there.
Docker容器是从Docker映像构建的。 默认情况下,Docker从Docker Hub提取这些映像, Docker Hub是由Docker项目背后的公司Docker管理的Docker注册表。 任何人都可以在Docker Hub上托管其Docker映像,因此您需要的大多数应用程序和Linux发行版都将托管映像。
To check whether you can access and download images from Docker Hub, type:
要检查是否可以从Docker Hub访问和下载映像,请输入:
The output will indicate that Docker in working correctly:
输出将表明Docker在正常工作:
-
-
-
-
- Output
-
- Unable to find image 'hello-world:latest' locally
- latest: Pulling from library/hello-world
- 1b930d010525: Pull complete
- Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8
- Status: Downloaded newer image for hello-world:latest
-
- Hello from Docker!
- This message shows that your installation appears to be working correctly.
- ...
Docker was initially unable to find the hello-world
image locally, so it downloaded the image from Docker Hub, which is the default repository. Once the image downloaded, Docker created a container from the image and the application within the container executed, displaying the message.
Docker最初无法在本地找到hello-world
映像,因此它从默认存储库Docker Hub下载了该映像。 下载映像后,Docker会根据映像创建一个容器,并执行该容器中的应用程序,显示消息。
You can search for images available on Docker Hub by using the docker
command with the search
subcommand. For example, to search for the Ubuntu image, type:
您可以使用docker
命令和search
子命令来search
Docker Hub上可用的映像。 例如,要搜索Ubuntu映像,请输入:
The script will crawl Docker Hub and return a listing of all images whose name match the search string. In this case, the output will be similar to this:
该脚本将对Docker Hub进行爬网,并返回名称与搜索字符串匹配的所有图像的列表。 在这种情况下,输出将类似于以下内容:
-
-
-
-
- Output
-
- NAME DESCRIPTION STARS OFFICIAL AUTOMATED
- ubuntu Ubuntu is a Debian-based Linux operating sys… 9704 [OK]
- dorowu/ubuntu-desktop-lxde-vnc Docker image to provide HTML5 VNC interface … 319 [OK]
- rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 224 [OK]
- consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC session… 183 [OK]
- ubuntu-upstart Upstart is an event-based replacement for th… 99 [OK]
- ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with ansible 97 [OK]
- neurodebian NeuroDebian provides neuroscience research s… 57 [OK]
- 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 50 [OK]
- ubuntu
- ...

In the OFFICIAL column, OK indicates an image built and supported by the company behind the project. Once you’ve identified the image that you would like to use, you can download it to your computer using the pull
subcommand.
在“ 官方”列中,“ 确定”指示由项目背后的公司构建并支持的图像。 一旦确定了要使用的图像,就可以使用pull
子命令将其下载到计算机上。
Execute the following command to download the official ubuntu
image to your computer:
执行以下命令,将正式的ubuntu
映像下载到您的计算机:
You’ll see the following output:
您将看到以下输出:
-
-
-
-
- Output
-
- Using default tag: latest
- latest: Pulling from library/ubuntu
- 5b7339215d1d: Pull complete
- 14ca88e9f672: Pull complete
- a31c3b1caad4: Pull complete
- b054a26005b7: Pull complete
- Digest: sha256:9b1702dcfe32c873a770a32cfd306dd7fc1c4fd134adfb783db68defc8894b3c
- Status: Downloaded newer image for ubuntu:latest
After an image has been downloaded, you can then run a container using the downloaded image with the run
subcommand. As you saw with the hello-world
example, if an image has not been downloaded when docker
is executed with the run
subcommand, the Docker client will first download the image, then run a container using it.
下载映像后,可以使用带有run
子命令的已下载映像来运行容器。 当你用电锯hello-world
例如,如果当图像尚未下载docker
与执行run
子命令,多克尔客户端将首先下载的图像,然后用它运行的容器。
To see the images that have been downloaded to your computer, type:
要查看已下载到计算机的图像,请键入:
The output should look similar to the following:
输出应类似于以下内容:
-
-
-
-
- Output
-
- REPOSITORY TAG IMAGE ID CREATED SIZE
- ubuntu latest 4c108a37151f 2 weeks ago 64.2MB
- hello-world latest fce289e99eb9 6 months ago 1.84kB
As you’ll see later in this tutorial, images that you use to run containers can be modified and used to generate new images, which may then be uploaded (pushed is the technical term) to Docker Hub or other Docker registries.
正如您将在本教程的后面看到的那样,可以修改用于运行容器的映像并用于生成新映像,然后可以将其上载(按技术术语推入 )到Docker Hub或其他Docker注册表中。
Let’s look at how to run containers in more detail.
让我们看看如何更详细地运行容器。
The hello-world
container you ran in the previous step is an example of a container that runs and exits after emitting a test message. Containers can be much more useful than that, and they can be interactive. After all, they are similar to virtual machines, only more resource-friendly.
您在上一步中运行的hello-world
容器是一个在发出测试消息后运行并退出的容器的示例。 容器可以比这有用得多,并且它们可以是交互式的。 毕竟,它们类似于虚拟机,但是对资源更友好。
As an example, let’s run a container using the latest image of Ubuntu. The combination of the -i and -t switches gives you interactive shell access into the container:
例如,让我们使用Ubuntu的最新映像运行一个容器。 -i和-t开关的组合使您可以交互式访问外壳:
Your command prompt should change to reflect the fact that you’re now working inside the container and should take this form:
您的命令提示符应更改以反映您正在容器内工作的事实,并应采用以下形式:
-
-
-
-
- Output
-
- root@d9b100f2f636:/#
Note the container id in the command prompt. In this example, it is d9b100f2f636
. You’ll need that container ID later to identify the container when you want to remove it.
注意命令提示符中的容器ID。 在此示例中,它是d9b100f2f636
。 您以后需要该容器ID来标识要删除的容器。
Now you can run any command inside the container. For example, let’s update the package database inside the container. You don’t need to prefix any command with sudo
, because you’re operating inside the container as the root user:
现在,您可以在容器内运行任何命令。 例如,让我们更新容器内的包数据库。 您不需要在任何命令前加上sudo
前缀,因为您是在容器内部以root用户身份进行操作的:
Then install any application in it. Let’s install Node.js:
然后在其中安装任何应用程序。 让我们安装Node.js:
This installs Node.js in the container from the official Ubuntu repository. When the installation finishes, verify that Node.js is installed:
这会将Node.js从官方Ubuntu存储库安装到容器中。 安装完成后,请验证是否已安装Node.js:
You’ll see the version number displayed in your terminal:
您会在终端中看到版本号:
-
-
-
-
- Output
-
- v8.10.0
Any changes you make inside the container only apply to that container.
您在容器内所做的任何更改仅适用于该容器。
To exit the container, type exit
at the prompt.
要退出容器,请在提示符下键入exit
。
Let’s look at managing the containers on our system next.
接下来让我们来看一下管理系统上的容器。
After using Docker for a while, you’ll have many active (running) and inactive containers on your computer. To view the active ones, use:
在使用Docker一段时间后,您的计算机上将有许多活动(运行)和非活动容器。 要查看活动对象 ,请使用:
You will see output similar to the following:
您将看到类似于以下内容的输出:
-
-
-
-
- Output
-
- CONTAINER ID IMAGE COMMAND CREATED
In this tutorial, you started two containers; one from the hello-world
image and another from the ubuntu
image. Both containers are no longer running, but they still exist on your system.
在本教程中,您启动了两个容器。 一个来自hello-world
映像,另一个来自ubuntu
映像。 这两个容器都不再运行,但是它们仍然存在于您的系统上。
To view all containers — active and inactive, run docker ps
with the -a
switch:
要查看所有容器(活动和非活动容器),请使用-a
开关运行docker ps
:
You’ll see output similar to this:
您将看到类似于以下的输出:
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- d42d0bbfbd35 ubuntu "/bin/bash" About a minute ago Exited (0) 20 seconds ago friendly_volhard
- 0740844d024c hello-world "/hello" 3 minutes ago Exited (0) 3 minutes ago elegant_neumann
To view the latest container you created, pass it the -l
switch:
要查看您创建的最新容器,请将-l
开关传递给它:
To start a stopped container, use docker start
, followed by the container ID or the container’s name. Let’s start the Ubuntu-based container with the ID of d9b100f2f636
:
要启动已停止的容器,请使用docker start
,后跟容器ID或容器的名称。 让我们启动ID为d9b100f2f636
的基于Ubuntu的容器:
docker start d42d0bbfbd35
码头工人开始d42d0bbfbd35
The container will start, and you can use docker ps
to see its status:
容器将启动,您可以使用docker ps
查看其状态:
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- d42d0bbfbd35 ubuntu "/bin/bash" About a minute ago Up 8 seconds friendly_volhard
To stop a running container, use docker stop
, followed by the container ID or name. This time, we’ll use the name that Docker assigned the container, which is friendly_volhard
:
要停止正在运行的容器,请使用docker stop
,后跟容器ID或名称。 这次,我们将使用Docker分配的容器名称,即friendly_volhard
:
docker stop friendly_volhard
码头工人停止friendly_volhard
Once you’ve decided you no longer need a container anymore, remove it with the docker rm
command, again using either the container ID or the name. Use the docker ps -a
command to find the container ID or name for the container associated with the hello-world
image and remove it.
一旦确定不再需要容器,请使用docker rm
命令再次使用容器ID或名称将其删除。 使用docker ps -a
命令查找与hello-world
映像关联的容器的容器ID或名称,并将其删除。
docker rm elegant_neumann
泊坞窗rm Elegant_neumann
You can start a new container and give it a name using the --name
switch. You can also use the --rm
switch to create a container that removes itself when it’s stopped. See the docker run help
command for more information on these options and others.
您可以启动一个新容器,并使用--name
开关为其命名。 您也可以使用--rm
开关创建一个容器,该容器在停止时会自行删除。 有关这些选项和其他选项的更多信息,请参阅docker run help
命令。
Containers can be turned into images which you can use to build new containers. Let’s look at how that works.
容器可以转换为映像,您可以使用它们来构建新的容器。 让我们看看它是如何工作的。
When you start up a Docker image, you can create, modify, and delete files just like you can with a virtual machine. The changes that you make will only apply to that container. You can start and stop it, but once you destroy it with the docker rm
command, the changes will be lost for good.
启动Docker映像时,可以像使用虚拟机一样创建,修改和删除文件。 您所做的更改将仅应用于该容器。 您可以启动和停止它,但是一旦使用docker rm
命令销毁它,更改将永远丢失。
This section shows you how to save the state of a container as a new Docker image.
本节说明如何将容器状态另存为新的Docker映像。
After installing Node.js inside the Ubuntu container, you now have a container running off an image, but the container is different from the image you used to create it. But you might want to reuse this Node.js container as the basis for new images later.
在Ubuntu容器中安装Node.js之后,您现在有了一个运行映像的容器,但是该容器与用于创建它的映像不同。 但是您以后可能希望重用此Node.js容器作为新映像的基础。
Then commit the changes to a new Docker image instance using the following command.
然后使用以下命令将更改提交到新的Docker映像实例。
docker commit -m "What you did to the image" -a "Author Name" container_id repository/new_image_name
docker commit -m“您对映像执行的操作” -a“作者名称” container_id 存储库 / new_image_name
The -m switch is for the commit message that helps you and others know what changes you made, while -a is used to specify the author. The container_id
is the one you noted earlier in the tutorial when you started the interactive Docker session. Unless you created additional repositories on Docker Hub, the repository
is usually your Docker Hub username.
-m开关用于提交消息,该消息可帮助您和其他人知道您所做的更改,而-a用于指定作者。 container_id
是您在本教程前面部分中启动交互式Docker会话时所注明的那个。 除非您在Docker Hub上创建了其他存储库,否则该repository
通常是您的Docker Hub用户名。
For example, for the user sammy, with the container ID of d9b100f2f636
, the command would be:
例如,对于用户sammy ,容器ID为d9b100f2f636
,命令将为:
docker commit -m "added Node.js" -a "sammy" d42d0bbfbd35 sammy/ubuntu-nodejs
码头工人提交-m“添加了Node.js” -a“ sammy ” d42d0bbfbd35 sammy / ubuntu-nodejs
When you commit an image, the new image is saved locally on your computer. Later in this tutorial, you’ll learn how to push an image to a Docker registry like Docker Hub so others can access it.
提交映像时,新映像将保存在本地计算机上。 在本教程的后面,您将学习如何将映像推送到Docker Hub等Docker注册表,以便其他人可以访问它。
Listing the Docker images again will show the new image, as well as the old one that it was derived from:
再次列出Docker映像将显示新映像,以及来自该映像的旧映像:
You’ll see output like this:
您将看到如下输出:
-
-
-
-
- Output
-
- REPOSITORY TAG IMAGE ID CREATED SIZE
- sammy/ubuntu-nodejs latest d441c62350b4 10 seconds ago 152MB
- ubuntu latest 4c108a37151f 2 weeks ago 64.2MB
- hello-world latest fce289e99eb9 6 months ago 1.84kB
-
In this example, ubuntu-nodejs
is the new image, which was derived from the existing ubuntu
image from Docker Hub. The size difference reflects the changes that were made. And in this example, the change was that NodeJS was installed. So next time you need to run a container using Ubuntu with NodeJS pre-installed, you can just use the new image.
在此示例中, ubuntu-nodejs
是新映像,它是从Docker Hub的现有ubuntu
映像派生的。 大小差异反映了所做的更改。 在此示例中,更改之处在于已安装NodeJS。 因此,下一次您需要使用预先安装了NodeJS的Ubuntu运行容器时,就可以使用新映像。
You can also build Images from a Dockerfile
, which lets you automate the installation of software in a new image. However, that’s outside the scope of this tutorial.
您还可以从Dockerfile
构建映像,该文件可让您自动在新映像中安装软件。 但是,这超出了本教程的范围。
Now let’s share the new image with others so they can create containers from it.
现在,让我们与其他人共享新图像,以便他们可以从中创建容器。
The next logical step after creating a new image from an existing image is to share it with a select few of your friends, the whole world on Docker Hub, or other Docker registry that you have access to. To push an image to Docker Hub or any other Docker registry, you must have an account there.
从现有映像创建新映像之后,下一个逻辑步骤是与您的几个朋友,Docker Hub上的整个世界或您有权访问的其他Docker注册表共享该映像。 要将映像推送到Docker Hub或任何其他Docker注册表,您必须在其中拥有一个帐户。
This section shows you how to push a Docker image to Docker Hub. To learn how to create your own private Docker registry, check out How To Set Up a Private Docker Registry on Ubuntu 14.04.
本节介绍如何将Docker映像推送到Docker Hub。 要了解如何创建自己的私有Docker注册表,请查看如何在Ubuntu 14.04上设置私有Docker注册表 。
To push your image, first log into Docker Hub.
要推送映像,请首先登录Docker Hub。
docker login -u docker-registry-username
docker登录-u docker-registry-username
You’ll be prompted to authenticate using your Docker Hub password. If you specified the correct password, authentication should succeed.
系统将提示您使用Docker Hub密码进行身份验证。 如果您指定了正确的密码,则身份验证应该成功。
Note: If your Docker registry username is different from the local username you used to create the image, you will have to tag your image with your registry username. For the example given in the last step, you would type:
注意:如果您的Docker注册表用户名与用于创建映像的本地用户名不同,则必须使用注册表用户名标记映像。 对于最后一步中给出的示例,您将键入:
docker tag sammy/ubuntu-nodejs docker-registry-username/ubuntu-nodejs
docker标签sammy / ubuntu-nodejs docker -registry-username / ubuntu-nodejs
Then you may push your own image using:
然后,您可以使用以下方法推送自己的图像:
docker push docker-registry-username/docker-image-name
docker push docker-registry-username / docker-image-name
To push the ubuntu-nodejs
image to the sammy repository, the command would be:
要将ubuntu-nodejs
映像推送到sammy存储库,命令为:
docker push sammy/ubuntu-nodejs
码头工人推萨米 / ubuntu-nodejs
The process may take some time to complete as it uploads the images, but when completed, the output will look like this:
上载图像时,该过程可能需要一些时间才能完成,但是完成后,输出将如下所示:
-
-
-
-
- Output
-
- The push refers to a repository [docker.io/sammy/ubuntu-nodejs]
- e3fbbfb44187: Pushed
- 5f70bf18a086: Pushed
- a3b5c80a4eba: Pushed
- 7f18b442972b: Pushed
- 3ce512daaf78: Pushed
- 7aae4540b42d: Pushed
-
- ...
-
-

After pushing an image to a registry, it should be listed on your account’s dashboard, like that show in the image below.
将图片推送到注册表后,应在您的帐户的信息中心上列出该图片,如下图所示。
If a push attempt results in an error of this sort, then you likely did not log in:
如果推送尝试导致此类错误,则您可能未登录:
-
-
-
-
- Output
-
- The push refers to a repository [docker.io/sammy/ubuntu-nodejs]
- e3fbbfb44187: Preparing
- 5f70bf18a086: Preparing
- a3b5c80a4eba: Preparing
- 7f18b442972b: Preparing
- 3ce512daaf78: Preparing
- 7aae4540b42d: Waiting
- unauthorized: authentication required
Log in with docker login
and repeat the push attempt. Then verify that it exists on your Docker Hub repository page.
使用docker login
并重复推送尝试。 然后验证它是否存在于您的Docker Hub存储库页面上。
You can now use docker pull sammy/ubuntu-nodejs
to pull the image to a new machine and use it to run a new container.
您现在可以使用docker pull sammy / ubuntu-nodejs
将映像拉到新机器上,并使用它运行新容器。
In this tutorial you installed Docker, worked with images and containers, and pushed a modified image to Docker Hub. Now that you know the basics, explore the other Docker tutorials in the DigitalOcean Community.
在本教程中,您安装了Docker,使用了图像和容器,并将修改后的图像推送到Docker Hub。 既然您已经了解了基础知识,请在DigitalOcean社区中探索其他Docker教程 。
翻译自: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-debian-10
debian docker
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。