{
    "url": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app",
    "locale": "en",
    "title": "Docker for your Laravel app · DeLaParra Services",
    "description": "Install Docker, run your Laravel app with a database using Laravel Sail or your own compose.yaml file, and understand the key Docker commands.",
    "alternates": {
        "en": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app",
        "nl": "https://delaparra-services.nl/nl/handleidingen/docker-voor-je-laravel-app"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.csv",
        "md": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.md",
        "json": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.json",
        "zip": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.zip",
        "pdf": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.csv",
            "encodingFormat": "text/csv",
            "name": "docker-voor-je-laravel-app.csv"
        },
        {
            "url": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.json",
            "encodingFormat": "application/json",
            "name": "docker-voor-je-laravel-app.json"
        },
        {
            "url": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.md",
            "encodingFormat": "text/markdown",
            "name": "docker-voor-je-laravel-app.md"
        },
        {
            "url": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.pdf",
            "encodingFormat": "application/pdf",
            "name": "docker-voor-je-laravel-app.pdf"
        },
        {
            "url": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.zip",
            "encodingFormat": "application/zip",
            "name": "docker-voor-je-laravel-app.zip"
        }
    ],
    "markdown": "# Docker for your Laravel app\n\nWith Docker, your app runs in **containers**: isolated mini-environments with exactly the right version of PHP, database and extras. If it works for you, it will also work for your colleague and on the server. You don’t need to install PHP, MySQL and Redis on your computer yourself.\n\nA few words you’ll often come across:\n\n- **Image:** the build configuration (for example, `php:8.3-fpm` or `mysql:8.4`).\n- **Container:** a running copy of an image.\n- **Volume:** storage that persists even after the container has stopped. This is where your database is stored, for example.\n- **Compose:** a single file (`compose.yaml`) that describes all your containers together.\n\n## Step 1: Install Docker\n\n- **Windows and macOS:** install **Docker Desktop** from docker.com. On Windows, enable **WSL 2** during installation.\n- **Linux:** Install **Docker Engine** and the Compose plugin via your distribution’s package manager (follow the official installation guide for your distribution).\n\nThen check in the terminal:\n\n```bash\ndocker --version\ndocker compose version\n```\n\n## Step 2 (the easiest route): Laravel Sail\n\nLaravel has its own Docker setup: **Sail**. From your project directory:\n\n```bash\ncomposer require laravel/sail --dev\nphp artisan sail:install      # kies bijvoorbeeld mysql en redis\n./vendor/bin/sail up -d       # start alles op de achtergrond\n```\n\nYour app is now running on `http://localhost`.. You can execute commands via Sail:\n\n```bash\n./vendor/bin/sail artisan migrate\n./vendor/bin/sail composer install\n./vendor/bin/sail npm run dev\n./vendor/bin/sail down        # stoppen\n```\n\nTip: create an alias called `sail` so you don’t have to keep typing `./vendor/bin/`.\n\n## Step 2 (alternative): your own compose.yaml\n\nIf you want to decide for yourself what plays, a simple setup would look like this:\n\n```yaml\nservices:\n  app:\n    build: .\n    ports:\n      - \"8000:8000\"\n    volumes:\n      - .:/var/www/html\n    env_file: .env\n    depends_on:\n      db:\n        condition: service_healthy\n  db:\n    image: mysql:8.4\n    environment:\n      MYSQL_DATABASE: app\n      MYSQL_ROOT_PASSWORD: secret\n    volumes:\n      - dbdata:/var/lib/mysql\n    healthcheck:\n      test: [\"CMD\", \"mysqladmin\", \"ping\", \"-h\", \"localhost\"]\n      interval: 10s\n      retries: 5\nvolumes:\n  dbdata:\n```\n\nPlease note: in `.env`, set `DB_HOST=db` (the name of the service), not `127.0.0.1`. Containers locate each other by name.\n\n## The commands you really need\n\n| Command | What it does |\n|---|---|\n| `docker compose up -d` | Start everything (`-d` = in the background) |\n| `docker compose ps` | Which containers are running? |\n| `docker compose logs -f app` | Live logs from the app (`-f` = follow) |\n| `docker compose exec app php artisan migrate` | Running a command inside the container |\n| `docker compose exec -it app bash` | Open a shell in the container |\n| `docker compose down` | Stop everything (data is retained) |\n| `docker compose build --no-cache` | Rebuild after a change to the Dockerfile |\n\n## Be careful with these commands\n\n- `docker compose down -v` also deletes your **volumes**, including your database.\n- `docker system prune -a --volumes` clears everything, including data.\n\nOnly use them if you are certain you no longer need the data. Do not let your AI assistant run them without asking first. The **docker-destructive-guardrails** skill can help with this.\n\n## Common problems\n\n- **\"port is already allocated\":\n- **“Connection refused” to the database:** use `DB_HOST=db` and wait until the database is healthy (health check).\n- **Files have the wrong owner (Linux):** Run commands via Sail or as your own user (`-u`).\n- **Slow on Windows:** Place your project in the WSL file system (`\\\\wsl$\\...`), not on `C:\\`.\n\n## Need help?\n\nWould you like to have your Laravel app professionally set up in Docker, including a production-ready configuration? This falls under **Custom software and web applications**.\n\n## Skills\n\n- [Docker Project Foundations] (/nl/skills/docker-project-foundations)\n- [Docker Compose Patterns] (/nl/skills/docker-compose-patterns)\n- [Docker Build Strategies] (/nl/skills/docker-build-strategies)\n- [Multi Stage Dockerfile] (/nl/skills/multi-stage-dockerfile)\n- [Docker Destructive Command Guardrails] (/nl/skills/docker-destructive-guardrails)\n\n## Related services\n\n- [Maatwerk software en webapplicaties] (/nl/services#service-03)\n\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "TechArticle",
                "@id": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app#article",
                "url": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app",
                "headline": "Docker for your Laravel app",
                "description": "Install Docker, run your Laravel app with a database using Laravel Sail or your own compose.yaml file, and understand the key Docker commands.",
                "inLanguage": "en",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app#dataset",
                "name": "Docker for your Laravel app",
                "description": "Install Docker, run your Laravel app with a database using Laravel Sail or your own compose.yaml file, and understand the key Docker commands.",
                "url": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app",
                "identifier": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app#article"
                },
                "publisher": {
                    "@type": "Organization",
                    "name": "DeLaParra Services",
                    "url": "https://delaparra-services.nl/"
                },
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/manuals#dataset",
                    "name": "Manuals for working on your own app",
                    "url": "https://delaparra-services.nl/manuals"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "docker-voor-je-laravel-app.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.csv",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "docker-voor-je-laravel-app.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.json",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "docker-voor-je-laravel-app.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.md",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "docker-voor-je-laravel-app.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.pdf",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "docker-voor-je-laravel-app.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app.zip",
                        "inLanguage": "en"
                    }
                ]
            }
        ]
    }
}