is really important for me to keep php and nodejs separate
I am confused by your query! Your node and php services are separated.
What exactly is your issue? It's not working?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I need to run php and node as two separate containers for Laravel. The tutorials for older versions of Laravel support this. However, version 10 is giving me problems. I am using Nginx as my web server. I also use Vite and Vue with Laravel. Can anyone advise me how to modify the configuration to make it work? t is really important for me to keep php and nodejs separate - I want to keep the containerization philosophy as much as possible.
docker-compose:
version: '3.8'
services:
php:
build:
context: ./docker/php
volumes:
- ./:/var/www/html
nginx:
image: nginx:1.25.0
ports:
- "80:80"
volumes:
- ./docker/nginx/lcs.conf:/etc/nginx/conf.d/default.conf
- ./:/var/www/html
working_dir: /var/www/html
node:
image: node:20.2
user: node
volumes:
- ./:/assets
working_dir: /assets
ports:
- 3000:3000
- 3001:3001
- 3009:3009
command: npm run dev
db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
MYSQL_DATABASE: "${DB_DATABASE}"
MYSQL_USER: "${DB_USERNAME}"
MYSQL_PASSWORD: "${DB_PASSWORD}"
volumes:
- mysql_data:/var/lib/mysql
volumes:
mysql_data:
Nginx:
server {
listen 80;
listen [::]:80;
server_name _;
root /var/www/html/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
access_log /dev/stdout;
error_log /dev/stdout;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Vite:
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
server: {
host: true,
port: 3009,
watch: {
usePolling: true
}
},
plugins: [
laravel({
input: [
'resources/sass/app.scss',
'resources/js/app.js',
],
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
resolve: {
alias: {
vue: 'vue/dist/vue.esm-bundler.js',
},
},
});
The final solution for me was to install some Linux distribution - WSL 2. I chose Fedora. Here I cloned the project to ~/ and everything works. VSC has to connect to WSL for it to see what it has. I'm using Rancher Desktop, so there was a WSL need to check. Let's see if something changes in the future and it goes better.
Please or to participate in this conversation.