如何获得在Docker中访问资源的权限?

时间:2020-02-29 14:17:56

标签: php docker

我有docker-compose.yml:

version: "2"
services:
  webserver:
    image: php:7.4.3-apache
    ports:
      - "8181:80"
    volumes:
    - ./myprojectfoldername:/var/www/html

然后我运行命令docker-compose up -d 打开localhost:8181并接收403:

Forbidden
You don't have permission to access this resource.

Apache/2.4.38 (Debian) Server at localhost Port 8181

我做错了什么?

1 个答案:

答案 0 :(得分:1)

这是因为运行apache docker容器的用户没有写访问文件的权限。您需要确保运行容器的用户有权访问文件(文件的所有者),或者使用root用户来运行apache服务器