编写DockerFile

新建一个文件,命名为:mycentosDockerFile,没有后缀名,内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
FROM centos
MAINTAINER ledao<f1203007469@gmail.com>

LABEL name="LeDao CentOS Image" \
build-date="2021-08-21"

ENV WORKPATH /home/
WORKDIR $WORKPATH

RUN yum -y install net-tools
RUN yum -y install vim

EXPOSE 80
CMD /bin/bash

创建镜像

命令的最后面有个英文句号.(少了句号不行)

1
docker build -f /home/dockerfile/mycentosDockerFile -t a6678696/mycentos:1.1 .

查看镜像构建历史

1
docker history 镜像id