Docker Dockerfile Use Example _docker

Source: Internet
Author: User
Tags openssl docker run

Dockerfile

From base Mirror

Maintainer maintain this information

What command runs run, plus run in front of the command

Add to add some files, copy files, will automatically extract

Workdir the current working directory

VOLUME Directory Mount

Expose Open ports

The run process has to be running

Combat: Building Nginx

wget http://xiazai.jb51.net/201611/yuanma/nginx-1.9.3 (jb51.net). rar

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz

#This is my dockerfile#version 1.0
#Author: hh 
#Base Image base mirroring from
CentOS
#MAINTAINER maintainer information
Maintainer hh Wang 
#ADD
ADD pcre-8.38.tar.gz/usr/local/srcadd nginx-1.9.3.tar.gz/usr/local/src 
#RUN
RUN yum-y Install wget gcc gcc-c++ make OpenSSL openssl-devel
Run useradd-s/sbin/nologin-m www 
#WORKDIR
workdir/usr/local/src/nginx-1.9.3 
run./configure-- Prefix=/usr/local/nginx--user=www--group=www--with-http_ssl_module--with-http_stub_status_module
with-pcre=/usr/local/src/pcre-8.38 && make && make install 
RUN echo ' daemon off; ' >>/usr/local/nginx/conf/nginx.conf 
#ENV定义环境变量
ENV path/usr/local/nginx/sbin: $PATH 
#EXPOSE Map port
expose CMD ["Nginx"]

Docker build-t Whh/nginx-file:v1.

Docker run-d-it-p 93:80--name nginx

Now look at the use of Dockerfile

Mirroring can be established by using the Docker build command.

Text file Dockerfile is usually required, as in the following example:

From Hub.c.163.com/library/nginx----based mirroring

Run echo "Hello World" >/etc/nginx/index.xml----append to the end of index.html

Expose---exposed 80 ports

Cmd ' nginx '----start Nginx service

After saving, run Docker build-t mynginx:1.0.

Then run Docker images and look at the mirrors that were built.

Via Docker run-d-P 8082:80--name nginx_web mynginx:1.0

Finally, access to Nginx's index.html content via http://ip:8081

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.