$ docker-compose up -d --remove-orphans
# To Tear Down
$ docker-compose down --volumesWhen ever any permission error just run
sudo chmod 777 -R <the-wp-site>create there files docker-compose.yml, php.dockerfile, nginx.conf in root of the project
docker-compose.yml file content
version: '3'
services:
mysql:
image: mysql:8
volumes:
- ./mysql_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: ecommerce_db
networks:
- net
phpmyadmin:
depends_on:
- mysql
image: phpmyadmin/phpmyadmin:5
restart: always
ports:
- '8080:80'
environment:
PMA_HOST: mysql
MYSQL_ROOT_PASSWORD: password
networks:
- net
php:
depends_on:
- mysql
build:
context: .
dockerfile: ./php.dockerfile
restart: always
volumes:
- ./:/var/www/html
command: bash -c "chmod -R 777 /var/www/html/media && docker-php-entrypoint php-fpm"
networks:
- net
nginx:
depends_on:
- php
image: nginx:1
restart: always
ports:
- "8000:80"
volumes:
- ./:/var/www/html
- ./nginx.conf:/etc/nginx/conf.d/default.conf
networks:
- net
networks:
net:php.dockerfile file content
FROM php:8-fpm
RUN docker-php-ext-install pdo pdo_mysql
WORKDIR /var/www/html
EXPOSE 9000nginx.conf file content
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.ht {
deny all;
}
}