Installation and Configuration Nginx Docker mount the Environment - Nginx

installation

Docker pulling Nginx mirror:

docker pull nginx
docker images

Here Insert Picture Description
Here Insert Picture Description

Create a mount directory:

mkdir -p /Users/acton_zhang/mydocker/mynginx/{conf,conf.d,html,logs}

Here Insert Picture Description

Enter the vessel and view the profile directory structure:

docker run -i -t nginx /bin/bash

Here Insert Picture Description

copy container configuration file to the host file you just created the following:

docker cp 4d65624dc26c:/etc/nginx/nginx.conf /Users/acton_zhang/mydocker/mynginx/conf/nginx.conf
docker cp 4d65624dc26c:/etc/nginx/conf.d/default.conf  /Users/acton_zhang/mydocker/mynginx/conf.d/default.conf

Here Insert Picture Description

Write default.conf profile:
The port to 81:
Here Insert Picture Description

Mount and start Nginx:

docker run -p 81:81 --name mynginx --privileged=true -v /Users/acton_zhang/mydocker/mynginx/html:/usr/share/nginx/html -v /Users/acton_zhang/mydocker/mynginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /Users/acton_zhang/mydocker/mynginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf -v /Users/acton_zhang/mydocker/mynginx/logs:/var/log/nginx -d nginx

Here Insert Picture Description

Good writing html files into html inside, then enter in the browser http: // ip: 81 Port:

Here Insert Picture Description

Published 671 original articles · won praise 1903 · Views 240,000 +

Guess you like

Origin blog.csdn.net/cold___play/article/details/104081498