如何基于现有映像创建新的docker映像? [英] How to create new docker image based on existing image?

查看:124
本文介绍了如何基于现有映像创建新的docker映像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用docker。我使用docker文件创建映像。如何从现有映像创建新映像?

I just started using docker. I create an image using docker file. How can I create a new image from that existing image?

推荐答案

您可以使用docker命令$ docker build -f docker_filename。,它将首先读取写有说明的Dockerfile并自动生成映像。 Dockerfile中的指令包含组装映像所需的命令。图像建立完成后,将为其分配一个图像ID。
可以将映像推送到Docker注册表中心。为此,用户必须在Docker注册表中心中创建一个帐户。

You can create a new image by using docker command $docker build -f docker_filename . , It will first read the Dockerfile where the instructions are written and automatically build the image. The instruction in the Dockerfile contains the necessary commands to assemble an image. Once, the image is build, it will be assigned an image id. The image can be pushed to the docker registry hub. For this, the user must create an account in the docker registry hub.

Dockerfile示例如下:

An example of Dockerfile looks like this,

FROM docker/whalesay:latest
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune -a | cowsay

在这里,第一条指令告诉新映像将使用docker / whalesay:latest映像。
第二条指令将运行两个命令。
第三条指令告诉您,在设置环境后,应运行 fortune -a命令。

Here, the first instruction tells the new image will be using docker/whalesay:latest image. The second instruction will run the two commands. And the third instruction tells that when the environment is set up "fortune -a" command should run.

这篇关于如何基于现有映像创建新的docker映像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆