Dockerfile自定义命令/指令

我一直在阅读Docker文档,如果可能创build一个自定义命令/指令,似乎无法解决。 基本上我需要做一个HTTP请求到外部服务来检索一些需要包含在我的容器中的资产。 而不是使用卷来引用它们,我想在构build过程中将它们有效地注入到容器中,有点像dependency injection。

假设您指的是使用http(HTTP GET)下载一些文件作为问题中的示例之一。 你可以试试这个

RUN wget https://wordpress.org/plugins/about/readme.txt 

要么

 RUN curl https://wordpress.org/plugins/about/readme.txt 

具有下载shell脚本的示例Dockerfile

 PROJ-DIR - files - test.sh - Dockerfile 

文件/ test.sh

 #!/bin/sh wget https://wordpress.org/plugins/about/readme.txt 

Dockerfile

 FROM centos:latest COPY files/test.sh /opt/ RUN chmod u+x /opt/test.sh RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY* RUN yes | yum install wget RUN /opt/test.sh RUN rm /opt/test.sh 

build立图像

 docker build -t test_img .