flssol's avatar
Level 4

Devcontainer fails to start

I have been working with sail on Win11/WSL2/Docker for a while. Now I have decided to see if the devcotnainers are a good fit for me, however, I fail to get it up and running.

The application resides on WSL2 / Ubuntu.

I read the devcontainer from \\wsl.localhost\Ubuntu-22.04\home\forge\app\.devcontainer\devcontainer.json:

{
	"name": "Dev Container",
	"dockerComposeFile": [
		"../docker-compose.yml"
	],
	"service": "laravel.test",
	"workspaceFolder": "/var/www/html",
	"customizations": {
		"vscode": {
			"extensions": [
			],
			"settings": {}
		}
	},
	"remoteUser": "sail",
	"postCreateCommand": "chown -R 1000:1000 /var/www/html 2>/dev/null || true"
}

When PHPStorm tries to build the dev container, it brings up every service (mysql, minio, redis, mailpit etc) and i can reach them. However, the main service, laravel.test fails to start with:

Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /wsl.localhost/Ubuntu-22.04/home/forge/app

I am confident that i am missing something extremely obvious...

0 likes
3 replies
LaryAI's avatar
Level 58

The error message you're encountering indicates that the Docker daemon is unable to find the specified bind mount source path. This is a common issue when working with Docker and WSL2, especially when paths are not correctly mapped or accessible.

Here are some steps you can take to resolve this issue:

  1. Verify the Path: Ensure that the path /wsl.localhost/Ubuntu-22.04/home/forge/app actually exists on your WSL2 filesystem. You can do this by opening a WSL2 terminal and navigating to the directory:

    cd /home/forge/app
    

    If the directory does not exist, you will need to create it or correct the path in your configuration.

  2. Check Docker Desktop Settings: Make sure that Docker Desktop is configured to use WSL2 and that the correct WSL2 distribution is enabled for Docker. You can check this in Docker Desktop under Settings > Resources > WSL Integration.

  3. Update the devcontainer.json Path: If the path is correct, ensure that the path in your devcontainer.json is correctly formatted. Sometimes, using the full path with /mnt/ can help:

    {
        "name": "Dev Container",
        "dockerComposeFile": [
            "../docker-compose.yml"
        ],
        "service": "laravel.test",
        "workspaceFolder": "/var/www/html",
        "customizations": {
            "vscode": {
                "extensions": [],
                "settings": {}
            }
        },
        "remoteUser": "sail",
        "postCreateCommand": "chown -R 1000:1000 /var/www/html 2>/dev/null || true"
    }
    

    Ensure that the docker-compose.yml file is correctly referencing the path as well.

  4. Check Docker Compose File: Open your docker-compose.yml file and verify the volume mount paths. Ensure that the paths are correctly specified and match the actual paths on your WSL2 filesystem.

  5. Restart Docker and WSL2: Sometimes, simply restarting Docker Desktop and your WSL2 instance can resolve path-related issues. You can restart WSL2 by running:

    wsl --shutdown
    

    Then, restart Docker Desktop.

  6. Permissions: Ensure that the user running Docker has the necessary permissions to access the specified path. You might need to adjust permissions using chmod or chown within WSL2.

By following these steps, you should be able to resolve the issue with the devcontainer failing to start due to an invalid mount configuration. If the problem persists, consider checking Docker logs for more detailed error messages.

flssol's avatar
Level 4

sail up -d runs without a problem. The path exists and is reachable. the devcontainer.json points to correct and functional compose YAML file. Docker Desktop 4.34.3 is given the access to both "default" distro and Ubuntu distro by name

flssol's avatar
Level 4

So lets start step-by-step, using isntallation isntructions

  1. in Terminal, connect to WSL2 Install only with redis, for speed
curl -s "https://laravel.build/example-app?with=redis&devcontainer" | bash

Finishes successfully.

  1. in Terminal, follow instructions:
./vendor/bin/sail up -d

successful, we have a running app, so I take it down, ./vendor/bin/sail down

  1. in PHPStorm, File > Remote Development > Devcontainer > new from local point to WSL folder as :
\\wsl.localhost\Ubuntu-22.04\home\forge\example-app\.devcontainer\devcontainer.json

Container starts redis, but fails to start laravel.test with

Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /wsl.localhost/Ubuntu-22.04/home/forge/example-app

VSCode starts without a problem though

Please or to participate in this conversation.