## dockerfile centos7
~~~
FROM centos:latest
MAINTAINER hiyang echohiyang@foxmail.com
RUN sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf
RUN echo "nameserver 114.114.114.114" > /etc/resolv.conf
RUN yum install -y yumdownloader screen
WORKDIR /mnt/
~~~
通过dockerfile制作镜像后,挂载指定目录到容器中,使用以下命令启动容器
~~~
docker run -it -v /home/data/docker/centos7/repo/:/mnt --rm centos7.3:v1 /bin/bash
~~~
在容器中执行
~~~
#!/bin/bash
# 安装工具
yum install -y gcc cc cmake epel-release python-setuptools perl java docker
# 安装小工具
yum install -y wget curl tree lrzsz telnet yum-utils net-tools iproute lsof man nmap screen numactl parted lsscsi htop iftop iotop ntp ntpdate createrepo
# 安装常用软件
yum install -y chrony vim-enhanced git openssl memcached redis mariadb-server supervisor
yum install -y blas libgfortran liblinear libnet
yum install -y nginx
# 生成元数据
find /var/cache/yum -name "*.rpm" -exec cp {} /mnt/repo \;
createrepo --update /mnt/repo
~~~