【Dockerfile】CentOS6.x中Docker通过Dockerfile构建常用的基础环境 # 设置基本的镜像,后续命令都以这个镜像为基础 FROM centos # 作者信息 MAI



【Dockerfile】CentOS6.x中Docker通过Dockerfile构建常用的基础环境

Dockerfile文件

# 设置基本的镜像,后续命令都以这个镜像为基础 
FROM centos
# 作者信息 
MAINTAINER  shangwu 
# RUN命令会在上面指定的镜像里执行任何命令 
RUN yum install wget -y  
RUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup  
RUN wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo  
RUN wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo  
RUN yum clean all
#RUN yum makecache
#RUN yum install -y iputils-ping
#RUN yum install -y nginx
RUN yum install -y httpd
RUN yum install -y curl
RUN yum install -y vim
RUN yum install -y net-tools
RUN yum install -y lrzsz


#暴露ssh端口
EXPOSE  80 
CMD /bin/bash

访问测试

[root@controller ~]# docker run -p 92:80 -it --name h2 centos7-base
[root@703ed0285964 /]# ps -ef|grep httpd
root        17     1  0 22:13 ?        00:00:00 grep --color=auto httpd
[root@703ed0285964 /]# whereis httpd   
httpd: /usr/sbin/httpd /usr/lib64/httpd /etc/httpd /usr/share/httpd
[root@703ed0285964 /]# service httpd restart
[root@703ed0285964 /]# ./usr/sbin/httpd 
[root@703ed0285964 /]# ps -ef|grep httpd
root        21     1  0 22:14 ?        00:00:00 ./usr/sbin/httpd
apache      22    21  0 22:14 ?        00:00:00 ./usr/sbin/httpd
apache      23    21  0 22:14 ?        00:00:00 ./usr/sbin/httpd
apache      24    21  0 22:14 ?        00:00:00 ./usr/sbin/httpd
apache      25    21  0 22:14 ?        00:00:00 ./usr/sbin/httpd
apache      26    21  0 22:14 ?        00:00:00 ./usr/sbin/httpd
root        28     1  0 22:14 ?        00:00:00 grep --color=auto httpd
[root@703ed0285964 /]# exit
exit




你可能感兴趣的:(【Docker】Centos6)