我正在尝试使用我从 CI 构建的站点设置 Docker 映像。我遇到的问题是我只想将文件夹中的文件复制到图像中的 htdocs。我想得到这样的结构:
相反,我在 htdocs 中获取了我的文件夹的副本
root@f0e2001f3a3d:/usr/local/apache2# ls
bin build cgi-bin conf error htdocs icons include logs modules
root@f0e2001f3a3d:/usr/local/apache2# cd htdocs
root@f0e2001f3a3d:/usr/local/apache2/htdocs# ls
WebGL index.html
root@f0e2001f3a3d:/usr/local/apache2/htdocs# cd WebGL
root@f0e2001f3a3d:/usr/local/apache2/htdocs/WebGL# ls
Build bkg.png css index.html js
我的 dockerfile 是:
FROM httpd:2.4
COPY build/WebGL /usr/local/apache2/htdocs
EXPOSE 80
您可以通过/
在COPY
指令末尾指定 a 来复制文件,而不是目录。例如:
源目录
$ ls -R
.:
Dockerfile htdocs
./htdocs:
bkg.png Build index.html js
$ cat Dockerfile
FROM alpine
COPY htdocs/ /tmp/files/
RUN ls -laR /tmp/files
建筑
$ docker build . --no-cache
Sending build context to Docker daemon 4.608kB
Step 1/3 : FROM alpine
---> d4ff818577bc
Step 2/3 : COPY htdocs/ /tmp/files/
---> d777a2fbcbb9
Step 3/3 : RUN ls -laR /tmp/files
---> Running in fbe75f1353aa
/tmp/files:
total 8
drwxr-xr-x 2 root root 4096 Aug 8 23:59 .
drwxrwxrwt 1 root root 4096 Aug 8 23:59 ..
-rw-rw-r-- 1 root root 0 Aug 8 23:12 Build
-rw-rw-r-- 1 root root 0 Aug 8 23:12 bkg.png
-rw-rw-r-- 1 root root 0 Aug 8 23:12 index.html
-rw-rw-r-- 1 root root 0 Aug 8 23:12 js
Removing intermediate container fbe75f1353aa
---> 5c2225edb987
Successfully built 5c2225edb987
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句