Dockerfile
FROM basic mirroring
MAINTAINER Maintains this information
What command to run by RUN? Add RUN to the command
ADD Add some files to it, copy files, and it will automatically decompress.
WORKDIR Current working directory
VOLUME directory mount
EXPOSE Open port
The RUN process must be run all the time
Practical combat: build nginx
wget http://xiazai./201611/yuanma/nginx-1.9.3().rar
wget ftp:///pub/software/programming/pcre/pcre-8.
#This is My first Dockerfile#version 1.0 #Author: hh #Base image Basic imageFROM centos #MAINTAINER Maintainer InformationMAINTAINER hh Wang #ADD ADD pcre-8. /usr/local/srcADD nginx-1.9. /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/ #ENV defines environment variablesENV PATH /usr/local/nginx/sbin:$PATH #EXPOSE Mapping PortsEXPOSE 80 CMD ["nginx"]
docker build -t whh/nginx-file:v1 .
docker run -d -it -p 93:80 --name nginx whh/nginx-file:v1
Let's take a look at the use of dockerfile
The docker build command can be used to create an image.
The text file Dockerfile is usually required, as follows:
from ./library/nginx ----Based mirroring
run echo "hello world" >/etc/nginx/ ----Append to the end
expose 80 ---Expose port 80
cmd 'nginx' ----Start nginx service
After saving, run docker build -t mynginx:1.0.
Then run docker images to view the built image.
via docker run -d -p 8082:80 --name nginx_web mynginx:1.0
Finally, access the content of nginx through http://ip:8081