#My Docker file contents are
FROM nginx
COPY /src /usr/share/nginx/html
#My docker compose file contents are
version: '2'
services:
app:
build: .
image: app:1.0.0
volumes:
- ./src:/usr/share/nginx/html
ports:
- "8080:80"
I'm getting following error when run docker-compose
*1 directory index of "/usr/share/nginx/html/" is forbidden
我尝试过授权目录 – >在/ usr /共享/ nginx的/ HTML
它不起作用.
I want to synch host directory with docker container.
最佳答案 我遇到了同样的问题,所以发布的答案可能会帮助其他人或其他人寻找同样的问题
我正在运行nginx官方图片.
docker run --rm --name some-nginx -p 8080:80 -v /test/html5-youtube.js/examples/:/usr/share/nginx/html -it nginx
我收到了这个错误.
[error] 8#8: *3 directory index of "/usr/share/nginx/html/" is *forbidden*, client: 172.17.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost:8080"
因此,当我检查目录权限时,它是错误的.
在我的情况下检查nginx.conf中的用户它是nginx所以更改文件权限.
cd /usr/share/nginx/html
chown nginx:nginx ./*
然后我就能从服务器得到响应.
172.17.0.1 - - [30/Oct/2018:09:04:52 +0000] "GET /html5-youtube.js HTTP/1.1" 404 571 "http://localhost:8080/player.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" "-"