覆盖Dockerfile中映像的ENV [英] Override FROM image's ENV in Dockerfile

查看:148
本文介绍了覆盖Dockerfile中映像的ENV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自下图: https://registry.hub.docker. com/u/cloudesire/activemq/dockerfile/

如果我想在子子docker文件中覆盖ACTIVEMQ_VERSION环境变量,我假设我将能够执行以下操作:

If I wanted to override the ACTIVEMQ_VERSION environment variable in my child docker file, I assumed I would be able to do something like the following:

FROM cloudesire/activemq:latest
MAINTAINER abc <abc@xyz.co.uk>
ENV ACTIVEMQ_VERSION 5.9.1
ADD ./src/main/resources/* /opt/activemq/conf/

但是,这似乎不起作用.诚然,我是Docker的新手,并且显然误解了一些东西.请有人可以解释为什么这行不通,以及如何/是否可以另一种方式实现它?

However this does not seem to work. Admittedly I am new to Docker and have obviously misunderstood something. Please could someone explain why this does not work, and how/if I can achieve it another way?

推荐答案

那是行不通的. cloudesire/activemq:latest图像构建已使用ACTIVEMQ_VERSION填充其图像层.所有基于版本5.11.1的ActiveMQ安装文件都已提取到其相应目录中.

That won't work. The ACTIVEMQ_VERSION has already been used by the cloudesire/activemq:latest image build to populate its image layers. All the ActiveMQ installation files based on version 5.11.1 are already extracted in their corresponding directories.

在您的Dockerfile中,您只能在已在那里构建的内容之上构建并添加文件.您自己的Dockerfile构建将不重新运行在其Dockerfile中描述的构建说明.

In your Dockerfile you only can build on top of what has already been build there and add your files. Your own Dockerfile build will not re-run the build instructions described in their Dockerfile.

如果需要基于5.9.1版的自己的cloudesire/activemq映像,则需要克隆其Dockerfile,在此处调整版本并在本地进行构建.因此,您可以在其上建立另一个Dockerfile.

If you need to have your own cloudesire/activemq image based on version 5.9.1 you need to clone their Dockerfile, adjust the version there and build it locally. So you could base your other Dockerfile on it.

这篇关于覆盖Dockerfile中映像的ENV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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