Docker Learning notes--docker boot Nginx Instance mount directory not enough permissions

Source: Internet
Author: User
Tags docker run

Today in the start of a Docker run Nginx instance, when the directory is mounted, access to the static directory, insufficient permissions

The commands executed are:

Docker run 
--name my-nginx 
-d-p 80:80 
--restart=always  
-v/cloud/nginx/webroot:/usr/share/nginx/ HTML:RW 
-v/cloud/nginx/log:/var/log/nginx 
-v/cloud/nginx/config/nginx.conf:/etc/nginx/nginx.conf:ro - 
D Nginx  

Description

1. Where/cloud/nginx/webroot is my host directory, used to store static face pages

2./cloud/nginx/log Store Log

3./cloud/nginx/config/nginx.conf as Nginx configuration file

Docker run 
--name my-nginx 
-d-p 80:80 
--restart=always 
-v/cloud/nginx/webroot:/usr/share/nginx/ HTML:RW 
-v/cloud/nginx/log:/var/log/nginx 
-v/cloud/nginx/config/nginx.conf:/etc/nginx/nginx.conf:ro - 
D Nginx

Use the View Log command to display the following:

2018/02/02 02:45:12 [ERROR] 5#5: *1 "/usr/share/nginx/html/index.html" is forbidden (13:permission denied), client:10.11 3.51, Server:localhost, Request: "get/http/1.1", Host: "10.11.3.86"
2018/02/02 02:45:12 [ERROR] 5#5: *1 "/usr/shar E/nginx/html/index.html "is forbidden (13:permission denied), client:10.11.3.51, Server:localhost, request:" Get/http /1.1 ", Host:" 10.11.3.86 "
After discovering that the host's directory permissions are not enough, so decisively plus parameters:

--privileged=true
The complete command is as follows:

Docker run 
--name my-nginx 
-d-p 80:80 
--restart=always 
--privileged=true 
-v/cloud/nginx/ WEBROOT:/USR/SHARE/NGINX/HTML:RW 
-v/cloud/nginx/log:/var/log/nginx 
-v/cloud/nginx/config/nginx.conf:/ Etc/nginx/nginx.conf:ro- 
D nginx

Plus boot container, access is 0k.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.