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 <nginx-container> -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 <nginx-container> 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 <nginx-container> bash
ping <host-ip>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容