Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

n212's avatar
Level 2

Docker: Vite error, cannot find files. (EMPTY_RESPONSE)

Hi. I'm trying to learn docker, but I get an error when I try to access my application through 127.0.0.1 8000.

Laravel works fine, when npm run dev isn't running I see that Laravel works and it asks me to run that command. When I do, however, I see an error in my console in my browser:

Failed to load resource: net::ERR_EMPTY_RESPONSE app.css:1

When I run docker compose run npm run dev I get the following output in my terminal:

  VITE v4.0.4  ready in 420 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

  LARAVEL v9.48.0  plugin v0.7.3

  ➜  APP_URL: http://localhost

docker-compose.yaml

version: '3.8'

services:
  server:
    # image: 'nginx:stable-alpine'
    build:
      context: .
      dockerfile: dockerfiles/nginx.dockerfile
    ports:
      - '8000:80'
      - 5173:5173
    volumes:
      - ./src:/var/www/html
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - php
      - mysql
  php:
    build:
      context: .
      dockerfile: dockerfiles/php.dockerfile
    volumes:
      - ./src:/var/www/html:delegated
  mysql:
    image: mysql:5.7
    env_file:
      - ./env/mysql.env
  composer:
    build:
      context: ./dockerfiles
      dockerfile: composer.dockerfile
    volumes:
      - ./src:/var/www/html
  artisan:
    build:
      context: .
      dockerfile: dockerfiles/php.dockerfile
    volumes:
      - ./src:/var/www/html
    entrypoint: [ 'php', '/var/www/html/artisan' ]
  npm:
    image: node:14
    working_dir: /var/www/html
    entrypoint: [ 'npm' ]
    volumes:
      - ./src:/var/www/html

I've been trying to debug this for a few hours now, with no success. I'm unsure how this works together, and maybe I'm skipping something very obvious here.

Do I need to add anything new into my docker-compose.yaml that I have missed? The APP_URL seems fine, but would the port 5173 make the error?

Thanks for any help in advance, and if more information is needed, I'll reply swiftly.

0 likes
0 replies

Please or to participate in this conversation.