将Dockerfile从Windows文件系统复制到Docker容器 [英] Dockerfile COPY from a Windows file system to a docker container

查看:696
本文介绍了将Dockerfile从Windows文件系统复制到Docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 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 更改为:

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

然后转到您的代码目录: cd Users / rburton / code

在该目录内,运行:
docker build -t< image_name> 。

这篇关于将Dockerfile从Windows文件系统复制到Docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆