Windows路径的dockerfile [英] dockerfile with windows path

查看:399
本文介绍了Windows路径的dockerfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想启动COPY命令dockerfile来构建镜像docker,并将bash文件从主机(windows 10)复制到ubuntu镜像:

I would like to launch COPY command dockerfile for build image docker with copy bash file from host(windows 10) to ubuntu image like this :

COPY "C:\toto\directory_good\base.sh" /home/docker/scripts/base.sh

我尝试了很多可能性,但是我总是遇到相同的错误消息:

I try a lot of possibility but I always have the same error message :

lstat C:\base.sh: no such file or directory

我要配置和配置容器docker在我的Windows 10操作系统中有一些bash文件。

I want to provisionning and configurate my container docker with some few bash file in my windows 10 OS.

在Dockerfile中写入路径窗口的正确方法是什么。您是否有一个示例可以进一步了解操作方法?

What is the correct way to write path windows in Dockerfile. Do you have a example for more understand howto this ?

推荐答案

使用相对路径(未完全使用c:c限定,但相对于构建目录而言)并切换到正斜杠:

Use a relative path (not fully qualified with c:\, but relative to the build directory) and switch to forward slashes:

COPY scripts/base.sh /home/docker/scripts/base.sh

当您执行 docker build -t myimg:latest时。 ,最后一个告诉Docker客户端发送当前目录(不包括 .dockerignore )到docker引擎进行构建。 COPY ADD 命令不能包含该目录中未包含的所有内容。标准过程是将Dockerfile和所有需要的依赖项放在一个文件夹中,然后在该文件夹中进行构建。

When you do a docker build -t myimg:latest ., the last . tells the docker client to send the current directory (excluding anything listed in .dockerignore) to the docker engine to do the build. Anything not included in that directory cannot be included with a COPY or ADD command. The standard process is to place your Dockerfile and all needed dependencies in a single folder, and do your build inside that folder.

还请注意,1.12添加了更改从Linux / Unix所使用的反斜杠转为反引号的转义字符。这是在Dockerfile顶部的特殊转义指令中定义的,前缀为。我不建议您使用针对Linux主机构建的映像来执行此操作:

Also note that 1.12 added the ability to change the escape character from the backslash that Linux/Unix uses to a backtick. This is defined in a special escape directive at the top of your Dockerfile, prefixed with a #. I wouldn't recommend doing this with images you're building for Linux hosts:

# escape=`

# Example Dockerfile with escape character changed

FROM windowsservercore
COPY testfile.txt c:\
RUN dir c:\

这篇关于Windows路径的dockerfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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