/docker-php/docker-compose.yml
services:
php:
build:
context: .
dockerfile: Dockerfile
container_name: docker-php
volumes:
- .:/usr/share/nginx/html/docker-php
networks:
- docker-php
nginx:
image: nginx:latest
container_name: docker-nginx
ports:
- 80:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- .:/usr/share/nginx/html/docker-php
networks:
- docker-php
networks:
docker-php:
driver: bridge
/docker-php/Dockerfile
FROM php:8.3-fpm
WORKDIR /usr/share/nginx/html/docker-php
/docker-php/nginx.conf
server {
listen 80;
listen [::]:80;
root /usr/share/nginx/html/docker-php/public;
index index.php index.html index.htm;
location ~ .php$ {
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
/docker-php/public/index.php
<?php phpinfo(); ?>- docker compose up -d
[+] Running 3/3
✔ Network docker-php_docker-php Created 0.9s
✔ Container docker-nginx Started 1.7s
✔ Container docker-php Started 1.7s