docker_File 执行报错总结

编写dockerfile
[root@linux-node1 ~/dk]# cat Dockerfile
# this is a docker File
FROM centos  
MAINTAINER Leo
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
RUN curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
RUN yum -y install nginx
ADD index /usr/share/nginx/html/index.html
# 声明80端口
EXPOSE 80
# 启动的时候执行什么命令
CMD ['NGINX']
使用Dockerfile

我们编写好后,使用dockerfile,发现存在下面的错误

[root@linux-node1 ~/dk]# docker build ./ -t "test/run_nginx"
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /root/dk/Dockerfile: no such file or directory

[root@linux-node1 ~/dk]# ls
DockerFile

解决上面的错误有两种方法,任选其一即可。

  • 重命名dockerfile文件名,把DockerFile改为Dockerfile
  • 指定dockerfile,使用-f ,比如:docker build -t "test/run_nginx" -f DockerFile .

我这里选择第一种排错方式,排错后,我们执行看下

[root@linux-node1 ~/dk]# docker build -t "test/run_nginx" .
重定义镜像信息

查看下镜像下

[root@linux-node1 ~/dk]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              c9d76aeae590        3 minutes ago       388 MB
docker.io/centos    latest              e934aafc2206        2 weeks ago         199 MB
docker.io/alpine    latest              3fd9065eaf02        3 months ago        4.15 MB

我们重定义下镜像信息,使得可以认出是我们自己编写的。

[root@linux-node1 ~/dk]# docker tag  c9d76aeae590  leo:nginx
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值