前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Dockerfile

Dockerfile

作者头像
零月
发布2018-04-25 15:20:09
9310
发布2018-04-25 15:20:09
举报
文章被收录于专栏:从零开始的linux从零开始的linux
Dockerfile
代码语言:javascript
复制
 ############################################################
 # Dockerfile to build Nginx Installed Containers
 # Based on CentOS
 ############################################################
 # Set the base image to CentOS
 FROM centos
 # File Author / Maintainer
 MAINTAINER alex
 # Install necessary toolsRUN yum install -y pcre-devel wget net-tools gcc
 RUN yum install -y zlib zlib-devel make
 RUN yum install -y openssl-devel# Install Nginx
 ADD http://nginx.org/download/nginx-1.8.0.tar.gz .
 RUN tar zxvf nginx-1.8.0.tar.gz
 RUN mkdir -p /usr/local/nginxRUN cd nginx-1.8.0 && ./configure --prefix=/usr/local/nginx && make && make install
 RUN rm -fv /usr/local/nginx/conf/nginx.conf
 COPY .nginx_conf /usr/local/nginx/conf/nginx.conf
 # Expose ports
 EXPOSE 80
 # Set the default command to execute
 # when creating a new container
 CMD /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
创建镜像
代码语言:javascript
复制
 # docker build -t centos_nginx .Sending build context to Docker daemon   554 MBSending build context to Docker daemon Step 0 : FROM centos ---> bac949ce964bStep 1 : MAINTAINER aming aming@aminglinux.com ---> Using cache ---> c2065048b72aStep 2 : RUN yum install -y pcre-devel wget net-tools gcc ---> Using cache ---> 05fa4cc1856fStep 3 : RUN yum install -y zlib zlib-devel make ---> Using cache ---> 99960731c759Step 4 : RUN yum install -y openssl-devel ---> Using cache ---> 1f3cc9ae48cdStep 5 : ADD http://nginx.org/download/nginx-1.8.0.tar.gz .Downloading 832.1 kB/832.1 kB ---> Using cache ---> 16d6f68fea77Step 6 : RUN tar zxvf nginx-1.8.0.tar.gz ---> Using cache ---> 4df46e512943Step 7 : RUN mkdir -p /usr/local/nginx ---> Using cache ---> 865f9d97d9e5Step 8 : RUN cd nginx-1.8.0 && ./configure --prefix=/usr/local/nginx && make && make install ---> Using cache ---> b997c1dce057Step 9 : RUN rm -fv /usr/local/nginx/conf/nginx.conf ---> Using cache ---> 857e27129832Step 10 : COPY .nginx_conf /usr/local/nginx/conf/nginx.conf ---> 3a300ffbcfa3Removing intermediate container bc3bdb68a3c2Step 11 : EXPOSE 80 ---> Running in 6a8c267e92b6 ---> 20c46a5b0b57Removing intermediate container 6a8c267e92b6Step 12 : CMD /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ---> Running in 0b626e465eaa ---> 54caaabd2c3bRemoving intermediate container 0b626e465eaaSuccessfully built 54caaabd2c3b
启动

docker run -itd -P centos_nginx bash

docker exec -it 398a bash

398a6248bb74 centos_nginx "bash" 4 minutes ago Up 4 minutes 0.0.0.0:32768->80/tcp agitated_banach

代码语言:javascript
复制
 # curl 127.0.0.1:32768<!DOCTYPE html><html><head><title>Welcome to nginx!</title><style>    body {        width: 35em;        margin: 0 auto;        font-family: Tahoma, Verdana, Arial, sans-serif;    }</style></head><body><h1>Welcome to nginx!</h1><p>If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.</p><p>For online documentation and support please refer to<a href="http://nginx.org/">nginx.org</a>.<br/>Commercial support is available at<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p></body></html>
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-06-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 从零开始的linux 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Dockerfile
  • 创建镜像
  • 启动
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档