Dockerhub automated build fails, “not a directory” when adding file

╄→гoц情女王★ 提交于 2019-12-23 11:49:24

问题


I am trying to use docker hub to automatically build something that builds fine locally. It fails saying:

Build process failed: stat /var/lib/docker/aufs/mnt/1be9db483fa6f3de2596b5261e7c450de8df503185e579278396f14ba179c257/bin/run.sh: not a directory

You can view the build itself here: https://hub.docker.com/r/zbyte64/rethinkdb-tlsproxy/builds/bjclhq33kgwxxvn6nbfsgyh/

run.sh is in the same directory as Dockerfile, it seems the build path on dockerhub is different then where it stores the Dockerfile.

I have tried the following variations:

COPY run.sh /bin

ADD ./run.sh /bin


回答1:


The COPY command (on Dockerhub's Docker version) expects the target file on the right hand side, not just the target directory. The following command should work for you even on Dockerhub.

COPY run.sh /bin/run.sh



回答2:


Or if you want to use ADD, include the trailing slash. ADD ./run.sh /bin/

What is actually happening? From https://docs.docker.com/engine/reference/builder/#add : ADD src dest "If dest does not end with a trailing slash, it will be considered a regular file and the contents of src will be written at dest."

Without the trailing slash on /bin, it expects run.sh to be a directory being copied to directory /bin.




回答3:


I don't know why, but dockerhub wants the first argument of COPY or ADD to be a directory - not a file. I am running Docker 1.9.1 locally and that is not the case. I switched the Dockerfile to copy a resource directory instead of individual files and things started to work.



来源:https://stackoverflow.com/questions/35075418/dockerhub-automated-build-fails-not-a-directory-when-adding-file

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