php
php copied to clipboard
Host not found when using some version in php image
Hello, I am facing some error when I am using php:8, somehow my host is not found. But when I changed it into php:7.4-fpm-alpine it works
My Docker Compose
version: "3"
networks:
laravel:
services:
nginx:
image: nginx:stable-alpine
container_name: webserver
ports:
- "80:80"
volumes:
- ./src:/var/www/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
- mysql
networks:
- laravel
mysql:
image: mysql:8.0.22
container_name: database
restart: unless-stopped
tty: true
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: deployken
MYSQL_USER: root
MYSQL_PASSWORD: toor
MYSQL_ROOT_PASSWORD: toor
networks:
- laravel
php:
build:
context: .
dockerfile: Dockerfile
container_name: webapp
volumes:
- ./src:/var/www/html
networks:
- laravel
My PHP Dockerfile
#When using php:8 it not exposed ?
FROM php:7.4-fpm-alpine
RUN docker-php-ext-install pdo pdo_mysql
This is my Nginx default conf
server {
listen 80;
index index.php index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
What's the exact error, what do the docker logs show?
If you're using Nginx with php then you'd want the fpm variant, the normal variant has Apache https://github.com/docker-library/docs/tree/master/php#phpversion-fpm
You could also try asking over at the Docker Community Forums, Docker Community Slack, or Stack Overflow. Since these repos aren't really a user-help forum