简体   繁体   中英

Docker: Forbidden You don't have permission to access this resource

Im trying to reach http://localhost:8100 and all i get is: "Forbidden

You don't have permission to access this resource.

Apache/2.4.38 (Debian) Server at localhost Port 8100"

In the src/ i have the docker file and a php folder in which i have both index.php and mysql.php files. The docker-compose.yml looks like this:

version: '3'

services:
  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: test_db
      MYSQL_USER: devuser
      MYSQL_PASSWORD: devpass
    ports:
      - "9906:3306"
  web:
    image: php:7.4.0-apache
    container_name: php_web
    depends_on:
      - db
    volumes:
      - ./php/:/var/www/html/
    links:
      - db
    ports:
      - "8100:80"
    stdin_open: true
    tty: true

Commands on the terminal:

docker-compose up -d
docker exec -ti php_web sh
docker-php-ext-install mysqli

When I try to reach localhost:8100/mysql.php it works fine but when i try to open either localhost:8100 or localhost:8100/index.php I get the error.

Any clues on what could be causing it? I hope Im being clear with my question.

Thanks in advance!

As per output of docker exec -ti php_web ls -la /var/www/html/ , i can see space in the name of the file:

-rw-r--r-- 1 root root 70 Jul 11 23:06 ' index.php'
drwxr-xr-x 5 root root 160 Jul 11 22:40 . 
drwxr-xr-x 1 root root 4096 Nov 22 2019 .. 
drwxr-xr-x 4 root root 128 Jul 11 22:31 includes 
-rwxr-xr-x 1 root root 118 Jul 11 22:43 mysql.php

rename it and remove the space

mv ' index.php' index.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM