Tips when setup Nginx Docker

Default configuration file inside Nginx docker is located under /etc/nginx/conf.d, named default.conf.
Be aware that the file name is a little bit different from default one on Ubuntu. On Ubuntu, it's located and named /etc/nginx/sites-available/default, while on Nginx docker it's located and named /etc/nginx/conf.d/default.conf.

  • Run the Nginx docker in detach (or say daemon) mode, and mount local /etc/nginx/sites-available/ folder to /etc/nginx/conf.d/ in docker.
docker run --name  -v /etc/nginx/sites-available/:/etc/nginx/conf.d -d nginx
  • If you want to check something inside Nginx docker, run below:
docker exec -it  bash
  • If there's something wrong with access to Nginx docker, firstly you want to check if ping works correctly, but ping by default is not installed in Nginx docker, so run below command to install ping:
apt update
apt install iputils-ping
docker exec -it  bash
ping 

你可能感兴趣的:(Tips when setup Nginx Docker)