首页 > 代码库 > docker创建镜像

docker创建镜像

手动创建:

docker run -d -p mynginx:v2 nginxrpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpmyum install nginx -yvi /etc/nginx/nginx.confdaemon off;docker ps -adocker commit a823e15f958b oldboyedu/mynginx:v3docker run -d -p 80:80 oldboyedu/mynginx:v3 nginx

 

用Dockerfile创建:

mkdir -p /opt/dockerfile/nginxecho <h1>test index</h1> > index.html[root@lanny nginx]# cat Dockerfile FROM centosMAINTAINER lanny.ma iher@foxmail.comWORKDIR /etc/yum.repos.d/ADD CentOS-Base.repo /etc/yum.repos.d/RUN rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpmRUN yum install nginx -yWORKDIR /etc/nginxRUN echo daemon off; >> /etc/nginx/nginx.confADD index.html /usr/share/nginx/htmlVOLUME ["/etc/nginx"]VOLUME ["/usr/share/nginx/html"]VOLUME ["/var/www"]EXPOSE 80 443CMD ["nginx"]

 

docker build -t oldboyedu/mynginx:v4 /opt/dockerfile/nginx/
docker run -d -p 80:80 oldboyedu/mynginx:v4
docker ps -a

docker创建镜像