Install the Docker

Official have different distributions under Linux (centos, Ubuntu, etc.) installation documentation: docs.docker.com/engine/inst…

Docker starts automatically after startup

systemctl enable docker

Docker sets the address of the domestic mirror

Source: www.daocloud.io/mirror

The curl – sSL get. Daocloud. IO/daotools/se… | sh -s f1361db2.m.daocloud.io

Install Nginx

If no nginx image is available locally, it will automatically go to the central repository to find it

docker run –name nginx -d -p 80:80 nginx

Verify success

Enter http://server IP address. If the nginx welcome page is displayed, it is successful

Configuration Information Mapping

If you need to modify the configuration file after the installation is very troublesome, you need to map the configuration file for easy modification!!

Create folders on the host for mapping

Mkdir -p /home/nginx/conf to save configuration files mkdir -p /home/nginx/ HTML to save HTML mkdir -p /home/nginx/logs to save configuration files

Make a copy of the configuration file

docker cp nginx:/etc/nginx/nginx.conf /home/nginx/conf

Remove the enabled nginx

docker stop nginx docker rm nginx

Run nginx /usr/share/nginx/html internal HTML file /etc/nginx/nginx.conf Internal nginx configuration file /var/log/nginx internal nginx log file

docker run --name nginx -v /home/nginx/html:/usr/share/nginx/html -v /home/nginx/conf/nginx.conf:/etc/nginx/nginx.conf  -v /home/nginx/logs:/var/log/nginx -d -p 80:80 nginx
Copy the code

Add index.html to /home/nginx/ HTML, then visit the url again and find out!!