docker十:docker-DockerFile案例-自定义CentOS镜像

 

1、编写DockerFile:

# 继承CentOS镜像
FROM centos

# 作者和邮箱
MAINTAINER zyh<9077@qq.com>

# 设置一个环境变量
ENV mypath /tmp

# 登录后的默认路径为 /tmp
WORKDIR $mypath

# 安装vim
RUN yum -y install vim
# 安装net-tools
RUN yum -y install net-tools

# 暴露80端口
EXPOSE 80

CMD /bin/bash

 

2、构建:docker build -t 新镜像的名字:TAG .

 

3、运行最新构建出来的镜像

3.1、登录过后默认路径为在DockerFile中设置的路径

3.2、DockerFile中指定安装的软件已安装

 

4、列出镜像的变更历史 docker history 镜像ID

 

posted @ 2021-07-11 21:51  向前走。  阅读(138)  评论(0编辑  收藏  举报