2014-10-16 90 views
7

試圖建立這個Dockerfile:Dockerfile COPY: 「lchown ......不是一個目錄」

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.confcaching.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/] 

回答

30

爲Dockerfile COPY指令的文件說:

如果<DEST>不以斜線結尾,將被視爲普通文件和<SRC>的內容將是寫在。

所以只需添加的目標目錄一個/,你將能夠建立你的形象:

COPY proxypass.conf /etc/apache2/sites-available/ 
COPY caching.conf /etc/apache2/conf-available/ 
+6

該錯誤消息還有待改進。 – seanmcl 2014-10-16 14:52:01

+0

它看起來像TravisCI上提供的默認Docker安裝仍然存在此錯誤。 Docker 1.11.2沒有。 – ocramz 2016-07-15 07:36:27

相關問題