Level 9
try to change your nginx port from 8080:80 to 80:80
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everyone. I'm new to docker . Im setting my own web dev stack with (nginx - php - laravel - mysql) in docker. The things im feeling stuck because look like Laravel not actually connect to my docker When i access to localhost . Google chrome give me
This site can’t be reached 127.0.0.1 refused to connect.
This is my basic setup of docker-compose.yml
3306:3306
9000:9000
8080:80
version: '3'
# Network : Laravel
networks:
laravel:
driver: bridge
services:
# ===================== Nginx =========================== #
nginx:
image: nginx:latest
restart: "always"
container_name: nginx
ports:
- 8080:80
# Mounts
volumes:
# - File config "." mean same level of file
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
# - Mount location for contains all projects
- /home/hoangtho/Projects/:/usr/share/nginx/html/
depends_on:
- php
- mysql
# - mysql - Need install mysql
networks:
- laravel
# ===================== PHP =========================== #
php:
image: php-7.4-fpm
container_name: php
ports:
- 9000:9000
build:
context: './php/'
# Volumes store my php file
volumes:
- /home/hoangtho/Projects/:/usr/share/nginx/html/
working_dir: /usr/share/nginx/html/
tty: true
networks:
- laravel
# ======================== Mysql ======================= #
mysql:
image: mysql:latest
container_name: mysql
ports:
- 3306:3306
environment:
# default database
MYSQL_DATABASE: default
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: hoangtho
MYSQL_PASSWORD: tho230697
networks:
- laravel
# ========================= End of config ========================= #
This is my .env of first-app
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:MbV5mxzv7u4P4b8nb+xk9848joWqZ3ULUw75ZIseaUo=
APP_DEBUG=true
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=default
DB_USERNAME=hoangtho
DB_PASSWORD=tho230697
server {
listen 80;
index index.php index.html;
server_name _;
root /usr/share/nginx/html/;
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;
}
}
FROM php:7.4-fpm-alpine
RUN docker-php-ext-install pdo mysqli
RUN curl -sS getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
I running in docker container php
Im stuck for 3 hours but i can't find out the way.. Please help
Please or to participate in this conversation.