900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > docker build no such file or directory

docker build no such file or directory

时间:2022-02-01 01:11:05

相关推荐

docker build  no such file or directory

在我构建新的镜像的时候, 发生 了no such file or directory 的错误。 这个错误找了半天, 没头绪, 后来灵光一现, 原来是我的文件夹名字写错了

我的目录结构是这样的

[root@host sample]# find ./ -type f./enginx/global.conf./enginx/nginx.conf./Dockerfile[root@host sample]# find ./ -type d././enginx[root@host sample]#

sample 文件夹中有一个Dockerfile 文件和一个nginx文件夹, nginx文件夹中有global.conf 和 nginx.conf

cd 进 sample 下 使用如下命令构建镜像

[root@host sample]# docker build -t addictions/nginx .

后面的“.” 表示当前目录, 会从当前目录去找Dockfile文件, 当前目录会被上传到docker进程作为构建上下文目录, 只有构建上下文目录的文件才可以被ADD 或者 COPY 到镜像中。

[root@host sample]# docker build -t addictions/nginx .Sending build context to Docker daemon 17.41 kBSending build context to Docker daemon Step 0 : FROM ubuntu---> 70d53b6cf65aStep 1 : MAINTAINER jxl "143154@"---> Using cache---> 0be2be8c6d47Step 2 : ENV REFRESHED_AT -10-21---> Using cache---> 48ead1b5bfb6Step 3 : RUN apt-get -yqq update && apt-get -yqq install nginx---> Using cache---> 3c834a6164b3Step 4 : RUN mkdir -p /var/www/html/website---> Using cache---> 5044773f5e09Step 5 : ADD nginx/global.conf /etc/nginx/conf.d/nginx/global.conf: no such file or directory

以上是我报的错, 原因是我我在Dockerfie中的ADD 命令中的文件夹名字写成了nginx, 而构建上下文目录中的文件夹是enginx。 不一致, 所以在上下文目录中找不到这个文件夹, 自然也找不到文件夹下的目录

解决方案: 将构建上下文目录中的enginx 改成 nginx 即可, 或者将Dockerfile中的ADD 命令后面的nginx 改成enginx, 以下是构建成功之后的输出

[root@host sample]# docker build -t addictions/nginx .Sending build context to Docker daemon 4.608 kBSending build context to Docker daemon Step 0 : FROM ubuntu---> 70d53b6cf65aStep 1 : MAINTAINER jxl "143154@"---> Using cache---> 0be2be8c6d47Step 2 : ENV REFRESHED_AT -10-21---> Using cache---> 48ead1b5bfb6Step 3 : RUN apt-get -yqq update && apt-get -yqq install nginx---> Using cache---> 3c834a6164b3Step 4 : RUN mkdir -p /var/www/html/website---> Using cache---> 5044773f5e09Step 5 : ADD nginx/global.conf /etc/nginx/conf.d/---> cfee19df85f2Removing intermediate container 0eddbc45f54dStep 6 : ADD nginx/nginx.conf /etc/nginx/nginx.conf---> dbf25a20d66dRemoving intermediate container 8fbdd8c0eb26Step 7 : EXPOSE 80---> Running in 0e4ef7402519---> 2b909217eb99Removing intermediate container 0e4ef7402519Successfully built 2b909217eb99[root@host sample]#

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。