Dockerfile COPY from a Windows file system to a docker container

二次信任 提交于 2019-12-22 05:14:45

问题


I have a simple Dockerfile:

FROM php:7.1-apache
LABEL maintainer="rburton@agsource.com"
COPY C:/Users/rburton/code/MyAgsourceAPI /var/www

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

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?


回答1:


First, change your Dockerfile to:

FROM php:7.1-apache
LABEL maintainer="rburton@agsource.com"
COPY MyAgsourceAPI /var/www

Then, to go your code directory: cd Users/rburton/code.

Within that directory, run: docker build -t <image_name> .



来源:https://stackoverflow.com/questions/46309423/dockerfile-copy-from-a-windows-file-system-to-a-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!