在Dockerfile中分离特定的configuration

我有一个泊坞窗图像的devise问题。 我创build了一个简单的Nginx图像,并在额外的文件中添加一些configuration。

这是我的Dockerfile:

FROM debian:wheezy RUN apt-get update && apt-get install -y wget && \ echo "deb http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list && \ echo "deb-src http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list && \ wget http://www.dotdeb.org/dotdeb.gpg && apt-key add dotdeb.gpg && \ apt-get update && apt-get install -y nginx RUN rm -rf /var/lib/apt/lists/* && \ echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \ chown -R www-data:www-data /var/lib/nginx ADD ./nginx/server.conf /etc/nginx/sites-available/default ADD ./nginx/extra_conf /etc/nginx/ .... 

有了这个,我想创build一个自动构build(从我的bitbucket帐户)在dockerregistry。 在构build期间,Docker需要有一个到nginx/server.conf/nginx/extra_conf 。 恕我直言,这种configuration是非常具体的用户/项目,不应该包括在这个级别(也可能不在版本中)。

我怎么能有更通用的东西?

我以为使用ONBUILD指令来添加我的文件,并创build一个Dockerfile子。 问题是,它创build了一个无用的inheritance级别。

Thx,关心

您可以使用卷,因此您可以将configuration文件存储在主机上的/path/to/nginx/conf.d

 docker run -v /path/to/nginx/conf.d:/etc/nginx/conf.d:ro nginx 

卷也适用于常规文件。

Interesting Posts