所谓定制镜像就是以一个镜像为基础,在其上进行定制。
- 运行环境:
CentOS 7.4 64位
1、创建存放Dockerfile 文件的目录
mkdir -p /usr/local/mydockerfile
2、进入存放Dockerfile 文件的目录
cd /usr/local/mydockerfile
3、创建Dockerfile
touch Dockerfile
4、编写 Dockerfile
vim Dockerfile
Dockerfile 内容
# 基于mono镜像
FROM mono
# 镜像维护人信息
MAINTAINER Jack Ma <123456@qq.com>
# 打印"这是我定制的hello-world"
CMD echo '这是我定制的hello-world'
6、构建镜像
docker build -t 127.0.0.1/hello-world .
构建完成:
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM mono
---> 13ed216b8ba5
Step 2/3 : MAINTAINER Jack Ma <123456@qq.com>
---> Running in 7204d6c33c20
Removing intermediate container 7204d6c33c20
---> b4a5deb1ee6a
Step 3/3 : CMD echo '这是我定制的hello-world'
---> Running in 74b2fc4591cd
Removing intermediate container 74b2fc4591cd
---> 5c66218781c1
Successfully built 5c66218781c1
Successfully tagged 127.0.0.1/hello-world:latest
7、运行定制的镜像
docker run -it 127.0.0.1/hello-world
打印定制信息:
这是我定制的hello-world