Docker start Nginx mirroring, configure the boot nginx proxy site on aspnetcore docker, modify and configure nginx configuration file

Start nginx on docker, modify and configure nginx configuration file

 

1. Download the docker docker image pull nginx nginx

2. Start nginx

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

This simply put nginx start, but we want to change the configuration file nginx.conf, into the container, the command:

docker exec -it nginx bash

nginx.conf configuration file in / etc / nginx / below, but you use vim nginx.conf or vi nginx.conf

Vi or vim command will find no use, the solution: apt-get install vim apt-get update after completion

At this point you can customize nginx.con files themselves, changing for the better after the restart configuration file container, steps, stopped first container

docker stop nginx then restart docker start nginx

This is not very convenient, there is a second way, mount configuration files, configuration files is to map nginx.conf with a host of top docker to start the nginx inside the container, which requires you to first prepare nginx.con profile If you should by ready, the next step is to start nginx

命令:docker run --name nginx -p 80:80 -v /home/docker-nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/docker-nginx/log:/var/log/nginx -v /home/docker-nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf -d nginx

Explain the above command:

--name to start your container a name, the name can be used later to start or stop the container

-p port mapping, the port 80 and container port 80 are bound host docker

-v mount the file, the first -v said it will cover your local nginx.conf you want to start from the container nginx.conf file, the second one is the log file to mount, it is to nginx server log writes you docker host of / home / docker-nginx / log / below

The third -v -v representation and a different meaning.

-d which represents the start of a mirror

I personally prefer the second way of mapping, the trouble is the need to be ready nginx.conf and default.conf documents myself, I was copied directly from inside the container, and then according to their needs reform

Have questions, please leave a message exchange.

1. Download the docker docker image pull nginx nginx

2. Start nginx

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

This simply put nginx start, but we want to change the configuration file nginx.conf, into the container, the command:

docker exec -it nginx bash

nginx.conf configuration file in / etc / nginx / below, but you use vim nginx.conf or vi nginx.conf

Vi or vim command will find no use, the solution: apt-get install vim apt-get update after completion

At this point you can customize nginx.con files themselves, changing for the better after the restart configuration file container, steps, stopped first container

docker stop nginx then restart docker start nginx

This is not very convenient, there is a second way, mount configuration files, configuration files is to map nginx.conf with a host of top docker to start the nginx inside the container, which requires you to first prepare nginx.con profile If you should by ready, the next step is to start nginx

命令:docker run --name nginx -p 80:80 -v /home/docker-nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/docker-nginx/log:/var/log/nginx -v /home/docker-nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf -d nginx

Explain the above command:

--name to start your container a name, the name can be used later to start or stop the container

-p port mapping, the port 80 and container port 80 are bound host docker

-v mount the file, the first -v said it will cover your local nginx.conf you want to start from the container nginx.conf file, the second one is the log file to mount, it is to nginx server log writes you docker host of / home / docker-nginx / log / below

The third -v -v representation and a different meaning.

-d which represents the start of a mirror

I personally prefer the second way of mapping, the trouble is the need to be ready nginx.conf and default.conf documents myself, I was copied directly from inside the container, and then according to their needs reform

Have questions, please leave a message exchange.

Guess you like

Origin www.cnblogs.com/davies/p/12147736.html