简体   繁体   English

如何保存Docker映像

[英]How to save a Docker image

I'm trying to follow a tutorial on https://www.ctl.io/developers/blog/post/docker-networking-rules/ , which contains the following: 我正在尝试遵循https://www.ctl.io/developers/blog/post/docker-networking-rules/上的教程,其中包含以下内容:

在此处输入图片说明

As I understand it, the code 据我了解,代码

FROM ubuntu:trusty
MAINTAINER Laura Frank <laura.frank@centurylink.com>
CMD while true; do echo 'hello world' | nc -l -p 8888; done

Is the content of a Dockerfile , which can be put in a newly created, empty directory and build using the command docker build . Dockerfile的内容,可以将其放置在新创建的空目录中,并使用命令docker build . .

I don't quite understand however how to 'name' the image no-exposed-ports ? 但是,我不太了解如何为no-exposed-ports “命名”? Am I supposed to use tagging (the -t option) as in the example in https://docs.docker.com/engine/tutorials/dockerimages/ ? 我是否应该按照https://docs.docker.com/engine/tutorials/dockerimages/中的示例使用标记( -t选项)?

I believe that by 'naming' the Docker image it is indeed meant that you use a tag. 我相信,通过“命名” Docker映像,确实意味着您使用了标签。 I used the command 我用的命令

docker build -t no-exposed-ports .

which gives the following response: 给出以下响应:

Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu:trusty
 ---> 3f755ca42730
Step 2 : CMD while true; do echo 'hello world' | nc -l -p 8888; done
 ---> Using cache
 ---> b8a7551d0ed9
Successfully built b8a7551d0ed9

From the command docker images I can see that no-exposed-ports is the name of the REPOSITORY , and the default tag latest has been assigned: 从命令docker images我可以看到, no-exposed-ports是名REPOSITORY ,默认标签latest已分配:

REPOSITORY                       TAG                 IMAGE ID            CREATED             SIZE
no-exposed-ports                 latest              b8a7551d0ed9        18 minutes ago      188 MB

Finally, running with the command 最后,使用命令运行

docker run -d --name no-exposed-ports no-exposed-ports

produces a long hash as in the example on the blog: 如博客示例所示,产生一个长哈希:

eb39d8ef68826510f4c964ad586ff04b9e334433538d9d69a39aa0ec44d6701f

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM