primary coverage :

* What is? Dockerfile
* see DockerHub Mirrored in Dockerfile
* Dockerfile to write
* Dockerfile Common commands
What is? Dockerfile

use Docker It is often necessary to customize new images based on existing images ,Dockerfile This process of image customization can be saved . Well written Dockerfile
after , You can reuse this file to build the same image on different machines .

see DockerHub Mirrored in Dockerfile

You can DockerHub Click the label on any image page in , see Dockerfile file , For example, click nginx Of latest label , notice nginx
Of Dockerfile:

Dockerfile to write

next , I can be in the official nginx Customization based on image . default nginx Page opening is like this :

The effect I want to achieve is page display :
I have changed the nginx page.

First, prepare the replacement index.html page :
  <body>I have changed the nginx page.</body>

to write Dockerfile:
#  from  nginx  Mirror start writing
FROM nginx:latest

#  Specify the default working directory for the container
WORKDIR /usr/share/nginx/html

#  Copy local files to  docker  in
COPY index.html index.html

stay index.html and Dockerfile Peer directory execute build instruction :
docker image build -t nginx_custom:latest .

next , adopt nginx_custom The name tag runs the container , visit 8000 Port can see the effect after customization .
docker container run -p 8000:80 nginx_custom:latest

Dockerfile Common commands


Must write , Indicates which base image to build from .
FROM untuntu
#  from  0  start
FROM scratch


working directory
WORKDIR /usr/share
#  Equivalent to operation  cd /usr/share


Add local file . General use COPY
COPY localfile /dest/file


Add environment variable .
ENV <key> <value> ENV <key>=<value> ...

Open port . Ports that the container can listen to . EXPOSE 80/udp , Agreement can be left blank . Note and run the program's -p distinguish .


Data volume .


Instructions to run , It could be shell format , Or it could be exec format .
RUN yum install wget
RUN ["yum", "install", "wget"]


One Dockerfile Only once in , Command to run when container is open . Like starting a python program : python Format also supports shell and
exec format .
CMD python

©2019-2020 Toolsou All rights reserved,
Redis Underlying data structure A person who dissuades others from learning computer , Are not good people win10 System computer C Where's the disc ,c disc users where? (win10c Disk not found users) Freshman c Language student management system ( lower ) hospital WIFI Which family is strong ? utilize Python Script unlimited spoof girlfriend computer C language program design —— Student management system Byte runout - Test development practice - One side cool meridian python Run code at specified time 5 Best style Linux Server system recommendation Anti anxiety life after naked resignation , I believe everything will have the best arrangement