[英]Read configuration file inside docker-compose or in docker file
Is it possible to read a configuration file eg json or yml file inside docker-compose and then parse the file and install the libraries listed in that file.是否可以在 docker-compose 中读取配置文件,例如 json 或 yml 文件,然后解析文件并安装该文件中列出的库。 For example例如
modules.json模块.json
{
"base": {
},
"myproject": {
"apcu": "php-apcu",
"memcache": "php-memcache",
"xmlrpc": "php-xmlrpc",
"mysql": "php-mysql",
"gd": "php-gd",
"soap": "php-soap",
"zip": "php-zip"
}
}
And then have this referenced in the.env file like MODULE=myproject然后在 MODULE=myproject 之类的 .env 文件中引用它
Inside the DockerFile I would then like to do在 DockerFile 里面我想做
RUN apt-get -y --no-install-recommends install php-apcu
etc? ETC?
In Dockerfile you should:在 Dockerfile 中,您应该:
Dockerfile example: Dockerfile 示例:
RUN apt-get install -y jq
COPY modules.json .
RUN cat modules.json | jq .myproject[] | sed -e 's/"//g' -e "s/'//g" | xargs apt-get -y --no-install-recommends install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.