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

reda1109's avatar

Laravel with Docker compose up error ( Solved )

Hi all, I have been learning Docker am liking the concept of it, one error I used to do was running the app from the docker desktop ( windows wsl debian btw ) and just hit the start button ( instead I shouldve been using docker-compose up or sail up ). To my suprise today I tried to do that just that ( run from cli ) and Ive been getting this error:

1 error(s) decoding:

*error decoding 'ports': No port specified: .:/var/www/html empty

This the docker-compose.yml :

services:
laravel.test:
    build:
        context: ./vendor/laravel/sail/runtimes/8.2
        dockerfile: Dockerfile
        args:
            WWWGROUP: '${WWWGROUP}'
    image: sail-8.2/app
    extra_hosts:
        - 'host.docker.internal:host-gateway'
    ports:
        - '${APP_PORT:-80}:80'
        - '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
    environment:
        WWWUSER: '${WWWUSER}'
        LARAVEL_SAIL: 1
        XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
        XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
        IGNITION_LOCAL_SITES_PATH: '${PWD}'
    volumes:
        - '.:/var/www/html'
    networks:
        - sail
    depends_on:
        - mysql
        - redis
        - phpmyadmin

 mysql:
    image: 'mysql/mysql-server:8.0'
    ports:
        - '${FORWARD_DB_PORT:-3306}:3306'
    environment:
        MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
        MYSQL_ROOT_HOST: '%'
        MYSQL_DATABASE: '${DB_DATABASE}'
        MYSQL_USER: '${DB_USERNAME}'
        MYSQL_PASSWORD: '${DB_PASSWORD}'
        MYSQL_ALLOW_EMPTY_PASSWORD: 1
        UPLOAD_LIMIT: 100000000
    volumes:
        - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
    networks:
        - sail
    healthcheck:
        test:
            - CMD
            - mysqladmin
            - ping
            - '-p${DB_PASSWORD}'
        retries: 3
        timeout: 5s

 redis:
    image: 'redis:alpine'
    command: redis-server --appendonly yes --requirepass "${REDIS_PASSWORD}"
    volumes:
        - ./data/redis:/data
    ports:
        - "8002:6379"
    networks:
        - sail
    healthcheck:
        test:
            - CMD
            - redis-cli
            - ping
        retries: 3
        timeout: 5s

 phpmyadmin:
    depends_on:
        - mysql
    image: 'phpmyadmin:latest'
    environment:
        PMA_HOST: mysql
        PMA_PORT: 3306
    networks:
        - sail
    ports:
        - "8077:80"
        - '.:/var/www/html'
networks:
   sail:
       driver: bridge

volumes:
    sailredis:
        driver: local

Also if you notice any errors in my config file, please show me the correct way to set this up, Also I followed the Official Laravel Sail method to make this.

0 likes
2 replies
alden8's avatar
alden8
Best Answer
Level 1

@reda1109

-- change the line ports: - "8077:80" - '.:/var/www/html' to:

ports:
  - "8077:80"

-- rebuild and restart the containers

docker-compose build
docker-compose up -d

-- using .env files for environment variables is often preferred for security and flexibility

-- consistent indentation enhances readability

-- reviewing network settings for inter-container communication is a good practice

1 like

Please or to participate in this conversation.