编写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
来源:https://www.cnblogs.com/liaojiafa/p/8901522.html