Dockerfile生成在ADD上产生lstat错误

我有一个简单的项目,结构如下:

docker/ |- src/ | |- config.json | |- Dockerfile 

json文件的内容:

 { "setting": "value" } 

Dockerfile的内容:

 FROM python:3.5 ADD src/config.json /testapp/config.json # Config 

我运行这个构build命令:

 docker build -t testapp:dev . 

并得到这个结果:

 Sending build context to Docker daemon 4.608 kB Step 1 : FROM python:3.5 ---> 1d0326469b55 Step 2 : ADD src/config.json /testapp/config.json lstat testapp/config.json: no such file or directory 

为什么这个失败? 为什么找不到的项目是testapp/config.json ? 在过去,我使用了这个确切的结构,例如,将requirements.txt文件复制到临时工作目录中。 我不明白我错过了关于如何工作,导致这失败了。 谁能解释一下?

我成了我的IDE的受害者。 这条线会失败:

 ADD src/config.json /testapp/config.json # Config 

但是这会成功:

 ADD src/config.json /testapp/config.json 

阅读添加的文档 ,它似乎试图使用Config作为目标目录,因此/testapp/config.json被视为源文件。 IDE灰显的# Config ,使我觉得它被视为一个评论:Dockerfiles不做内联评论。

Docker文档中对此进行了评论 :

Docker会将以#开头的行作为注释。 #行中的其他标记将被视为参数。