尝试构建此Dockerfile:
FROM dockerfile/ubuntu
RUN apt-get update && apt-get install -y apache2
COPY proxypass.conf /etc/apache2/sites-available
COPY caching.conf /etc/apache2/conf-available
RUN a2ensite proxypass \
&& a2enconf caching \
&& a2disconf serve-cgi-bin
EXPOSE 80
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
proxypass.conf
和caching.conf
文件与apache
一起位于Dockerfile
目录中。
运行docker build
会显示此输出:
$ sudo docker build -t me/apache apache
Sending build context to Docker daemon 29.7 kB
Sending build context to Docker daemon
Step 0 : FROM dockerfile/ubuntu
---> 77f8745ed183
Step 1 : RUN apt-get update && apt-get install -y apache2
---> Using cache
---> d62d92d91591
Step 2 : COPY proxypass.conf /etc/apache2/sites-available
2014/10/16 09:02:32 lchown /u01/docker/devicemapper/mnt/38bcd5cca695b4e9ac9af77e0342f85dea9fb10a238f7bd5173289bb956cf5c8/rootfs/etc/apache2/sites-available/proxypass.conf: not a directory
这是Oracle Linux 6.5(主要是CentOS 6.5)。
$ sudo docker info
Containers: 1
Images: 113
Storage Driver: devicemapper
Pool Name: docker-8:2-1308404-pool
Data file: /u01/docker/devicemapper/devicemapper/data
Metadata file: /u01/docker/devicemapper/devicemapper/metadata
Data Space Used: 4307.1 Mb
Data Space Total: 102400.0 Mb
Metadata Space Used: 5.5 Mb
Metadata Space Total: 2048.0 Mb
Execution Driver: native-0.2
Kernel Version: 2.6.32-358.23.2.el6.x86_64
Username: kgutwin
Registry: [https://index.docker.io/v1/]
答案 0 :(得分:32)
Dockerfile COPY指令的文档说:
如果< dest>不以尾部斜杠结尾,它将被视为常规文件和< src>的内容。将写在。
因此,只需为目标目录添加/
,即可构建图像:
COPY proxypass.conf /etc/apache2/sites-available/
COPY caching.conf /etc/apache2/conf-available/