I am new to docker
Here is my configuration
Folder Structure
Test :
- docker-compose.yml
- Dockerfile
- www
- index.html
Docker YML
version: "3"
services:
www:
build: .
ports:
- "8001:80"
volumes:
- ./www:/var/www/html/
links:
- db
networks:
- default
db:
image: mysql:8.0.16
command: ['--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci','--default-authentication-plugin=mysql_native_password']
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: myDb
MYSQL_USER: user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: test
volumes:
- ./dump:/docker-entrypoint-initdb.d
- persistent:/var/lib/mysql
networks:
- default
phpmyadmin:
image: phpmyadmin/phpmyadmin:4.8
links:
- db:db
ports:
- 8000:80
environment:
MYSQL_USER: user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: test
volumes:
persistent:
Dockerfile
FROM php:7.2.6-apache
RUN docker-php-ext-install mysqli pdo pdo_mysql gd curl
RUN a2enmod rewrite
RUN chmod -R 775 /var/www/html
phpmyadmin dashboard working correctly, But when i enter the web url it shows 403 forbidden error
When it check the log it shows an error like this :
[Mon Sep 02 12:00:44.290707 2019] [autoindex:error] [pid 18] [client 192.168.99.1:52312] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
192.168.99.1 - - [02/Sep/2019:12:00:44 +0000] "GET / HTTP/1.1" 403 508 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
and my “/var/www/html” directory was empty. How can i fix it ?
Update
I created a file index.php using bash it worked, but i can’t locate index.php file on my file system
Please help
If you need any additional info feel free to ask :).
Thanks
2
Answers
Finally i figured the issue, i am using docker toolbox so it only mount
C:Users
directory but my project folder is on d drive. so i have to mount myD:projects
directory to vm shared folder. i followed the below stepsAnd i change the docker-compose.yml like this :
i also updated the oracle vm. I found this solution from here : https://github.com/moby/moby/issues/22430#issuecomment-215974613 Thanks bro :)
You need to modify your Dockerfile,
This will copy your www dir to /var/www/html dir inside container, let your web service run.