Dockerfile 从 Windows 文件系统复制到 docker 容器 [英] Dockerfile COPY from a Windows file system to a docker container
问题描述
我有一个简单的 Dockerfile:
FROM php:7.1-apache
LABEL maintainer="rburton@agsource.com"
COPY C:/Users/rburton/code/MyAgsourceAPI /var/www
这是给我带来问题的最后一行.我正在从 Windows 结构复制到 docker 容器(我假设是 Linux).当我构建这个图像时,我得到:
It is the last line that is giving me problems. I am copying from a Windows structure to a docker container (Linux I assume). When I build this image I get:
...
Step 3/3 : COPY C:/Users/rburton/code/MyAgsourceAPI /var/www
COPY failed: stat /var/lib/docker/tmp/dockerbuilder720374851/C:/Users/rburton/code/MyAgsourceAPI: no such file or directory
首先,有些东西会阻止人们识别出这是一个绝对路径,如果路径前面带有 /var/lib/docker/tmp/dockerbuilder720374851
,那么自然会找不到该文件.其次,我尝试过 /
和 但结果都一样.我怀疑的驱动器号也让 docker 感到困惑.所以问题是如何将文件和文件夹(连同内容)从 Windows 文件夹复制到 docker 容器?
First, something is preventing the recognition that this is an absolute path and naturally if the path is pre-pended with /var/lib/docker/tmp/dockerbuilder720374851
then the file will not be found. Second, I have tried /
and but all with the same result. Also the drive letter I suspect is confusing to docker. So the question is how do I copy files and folders (along with the contents) from a Windows folder to a docker container?
推荐答案
首先,将你的 Dockerfile
更改为:
First, change your Dockerfile
to:
FROM php:7.1-apache
LABEL maintainer="rburton@agsource.com"
COPY MyAgsourceAPI /var/www
然后,进入你的 code
目录:cd Users/rburton/code
.
Then, to go your code
directory: cd Users/rburton/code
.
在该目录中,运行:docker build -t <image_name>.
这篇关于Dockerfile 从 Windows 文件系统复制到 docker 容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!