对 Dockerfile 的更改有效
ARG imagemagic_config=/etc/ImageMagick-6/policy.xml
RUN if [ -f $imagemagic_config ] ; then sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<policy domain="coder" rights="read|write" pattern="PDF" \/>/g' $imagemagic_config ; else echo did not see file $imagemagic_config ; fi
在运行时 (
docker run
),使用 绑定安装卷 覆盖容器内的 policy.xml
。
可以在 Docker Hub 上官方 Nginx 映像的如何使用此映像部分找到一个很好、简单的示例。
docker run --name some-nginx -v /some/content:/usr/share/nginx/html -d nginx
这里,
-v
标志是你的绑定挂载。 -v /some/content:/usr/share/nginx/html
表示“将容器中的 /usr/share/nginx/html
替换为我主机上 /some/content
的内容。用户的最终结果 -- 如果 /some/content
具有在 nginx 中确定的 index.html 或其他默认主页容器的 .conf 中,Nginx 不需要更改任何配置,因为默认的 Nginx 配置已经在该文件系统位置查找 index.html。
注意:绑定安装不是附加的。映像上的目录将完全被正在安装的目录替换。
或者在构建时 (
docker build
) 在 Dockerfile 中使用 COPY 将更新后的 policy.xml
直接烘焙到容器中,无需绑定安装。
COPY ./path/to/policy.xml /path/in/docker/image/policy.xml