覆盖Dockerfile中映像的ENV [英] Override FROM image's ENV in Dockerfile
问题描述
来自下图: 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屋!