在我构建新的镜像的时候, 发生 了  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 kB
Sending build context to Docker daemon
Step : FROM ubuntu
---> 70d53b6cf65a
Step : MAINTAINER jxl "2013143154@qq.com"
---> Using cache
---> 0be2be8c6d47
Step : ENV REFRESHED_AT --
---> Using cache
---> 48ead1b5bfb6
Step : RUN apt-get -yqq update && apt-get -yqq install nginx
---> Using cache
---> 3c834a6164b3
Step : RUN mkdir -p /var/www/html/website
---> Using cache
---> 5044773f5e09
Step : 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 kB
Sending build context to Docker daemon
Step : FROM ubuntu
---> 70d53b6cf65a
Step : MAINTAINER jxl "2013143154@qq.com"
---> Using cache
---> 0be2be8c6d47
Step : ENV REFRESHED_AT --
---> Using cache
---> 48ead1b5bfb6
Step : RUN apt-get -yqq update && apt-get -yqq install nginx
---> Using cache
---> 3c834a6164b3
Step : RUN mkdir -p /var/www/html/website
---> Using cache
---> 5044773f5e09
Step : ADD nginx/global.conf /etc/nginx/conf.d/
---> cfee19df85f2
Removing intermediate container 0eddbc45f54d
Step : ADD nginx/nginx.conf /etc/nginx/nginx.conf
---> dbf25a20d66d
Removing intermediate container 8fbdd8c0eb26
Step : EXPOSE
---> Running in 0e4ef7402519
---> 2b909217eb99
Removing intermediate container 0e4ef7402519
Successfully built 2b909217eb99
[root@host sample]#

docker build no such file or directory的更多相关文章

  1. Visual studio docker build no such file or directory

    在我构建新的镜像的时候, 发生 了  no such file or directory 的错误.  这个错误找了半天, 没头绪,项目结构是这样的: WebApplication1 建立在根目录下,是 ...

  2. docker 解决:Get http:///var/run/docker.sock/v1.19/version: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?

    docker 安装之后,通过命令查看docker相关信息时,可能会出现错误:Get http:///var/run/docker.sock/v1.19/version: dial unix /var/ ...

  3. Linux,Docker,Jenkins No such file or directory

    你们先休息下,我先哭哭! 今天在做交接项目的bug修改的时候,在创建文件的时候报错 No such file or directory 然后跟着路径去linux中查看了该路径,但确实存在,并且权限都是 ...

  4. failed to create rwlayer: lstat /var/lib/docker/overlay2/ no such file or directory

    在使用Docker构建微服务镜像时出现的错误.第一天构建好好的,第二天就出现了这样的错误.通过百度这条错误的信息非常少,只在 stackoverflow.com 上找到一条,问题指向了 dockerf ...

  5. Docker build 安装报错, Could not open requirments file: [Errno 2] No such file or directory:'requirements.txt'

    docker安装教程 https://docs.docker.com/get-started/part2/#build-the-app 相关帖子 https://stackoverflow.com/q ...

  6. Azure Devops: COPY failed: stat /var/lib/docker/tmp/docker-builder268095359/xxxxxxx.csproj no such file or directory

    在Azure Devops中部署docker镜像时,  出现COPY failed: stat /var/lib/docker/tmp/docker-builder268095359/xxxxxxx. ...

  7. docker load导入镜像报错:open /var/lib/docker/tmp/docker-import-970689518/bin/json: no such file or directory

    今天将之前打包好的mysql5.7.19的tar包通过docker load命令导入到Docker环境中却报出了如下错误: [root@host---- task]# docker load < ...

  8. dockercompose up build fail (node no such file or directory packages.json )

    docker构建项目遇到如下问题: npm ERR! Darwin 15.0.0 npm ERR! argv "/usr/local/lib/node_modules/iojs-bin/no ...

  9. docker :no such file or directory

    ---恢复内容开始--- 其中最主要的问题是:details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: ...

随机推荐

  1. bzoj3196:Tyvj1730二逼平衡树

    传送门 暴力啊,直接树套树上啊 线段树套splay,卡卡常就直接A了 代码: #include<cstdio> #include<iostream> #include<a ...

  2. python模块之struct

    # #********struct模块********# # 1.按照指定格式将Python数据转换为字符串,该字符串为字节流,如网络传输时, # 不能传输int,此时先将int转化为字节流,然后再发 ...

  3. Hive_Hive的管理_远程服务

    远程服务启动方式 - 端口号10000 - 启动方式: #hive --service hiveserver & 以JDBC或ODBC的程序登陆到hive中操作数据时,必须选用远程服务启动方式 ...

  4. python入门之迭代器

    迭代器 已知,可以直接作用于for循环的数据类型有: 一类是集合数据类型,如list.tuple.dict.set.str 一类是generator,包括生成器和带yield的generator fu ...

  5. python入门之实例-购买商品

    需求: 选择商品,结算所选的商品 #目前总资产 asset_all = 0 #所选商品总价 all_price = 0 #购物车列表,目前已选择商品 #每个元素的结构:"商品名": ...

  6. Spark Mllib里如何将数据集按比例随机地分成trainData、testData和validationData数据集(图文详解)

    不多说,直接上干货! 具体详情见 Hadoop+Spark大数据巨量分析与机器学习整合开发实战的第11章 电影推荐引擎

  7. Storm编程入门API系列之Storm的Topology多个Workers数目控制实现

    前期博客 Storm编程入门API系列之Storm的Topology默认Workers.默认executors和默认tasks数目 继续编写 StormTopologyMoreWorker.java ...

  8. JS脚本不能执行

    这段时间在做前端的动态页面,出了很多问题,因为js平时用的很少,所以花了不少无用功. 其中有两点一定要注意: 1.当js中有语法错误时,js脚本会无法执行. 2.当js脚本中有未定义的变量时,后边的语 ...

  9. Jquery测试纠错笔记

    一. 解析: 获取元素范围大小顺序依次为: $(#one).siblings("div")>$("#one~div")>$("#one + ...

  10. mysql 定时任务和存储过程

    mysql 定时任务和存储过程 最近在做日志系统,中间用到了 mysql, 其中有一个要求: 把数据库中 7天之后的日志清除了.看到 mysql 也支持 定时任务.于是就用 mysql 来做了.下面就 ...