laravel / sail

Docker files for running a basic Laravel application.
https://laravel.com/docs/sail
MIT License
1.65k stars 470 forks source link

sail up -d creates new docker container instead of using correct one #690

Closed MrLarkyy closed 2 months ago

MrLarkyy commented 4 months ago

Sail Version

1.29.1

Laravel Version

11.0.0

PHP Version

8.3.6

Operating System

Windows (WSL)

OS Version

23H2

Description

Hey I'm experiencing this issue whenever I run sail up -d I notice it creates a new docker container instead of using the previous already made one. This is occurring on a freshly installed Laravel application. I followed the Sail documentation for windows

Steps To Reproduce

follow the documentation Then:

pb30 commented 4 months ago

What exact commands are you running to reproduce this?

TwqntysJr commented 4 months ago

I'm experiencing the same issue exactly like described

The new instance of the docker containers are created when I run ./vendor/bin/sail up -d

pb30 commented 4 months ago

How are you stopping the project? Is this on a fresh project with unmodified docker-compose?

MrLarkyy commented 4 months ago

Hey! It is a fresh project. Ive tried to make multiple of the projects, it always happens. Only thing that I use is the sail up -d command

MrLarkyy commented 4 months ago

image It always creates a new container with random UUID.

image

Here you can see that it even shows the UUID in the console.

github-actions[bot] commented 4 months ago

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

Jubeki commented 4 months ago

Does WSL show a different folder name each time you start WSL? Because the container name is determined from the current folder you are in.

Maybe there is a way to set the container name via an .env entry. Probably needs a PR to sail.

MrLarkyy commented 4 months ago

The thing is that it did work at the first time. I've called my project testapp and even in wsl was testapp shown as well as in my docker. Another thing is that sometimes it works and sometimes it just creates a completely new container with random name as you can see on the screenshots. It is really strange.

Jubeki commented 4 months ago

So the problem itself does not lie with Sail but with Docker / WSL: https://docs.docker.com/compose/project-name/

You can attempt a PR where the project-name is defined in .env and added to the docker compose command. If no .env variable is defined the project folder should be used.

Why WSL sometimes mounts another random folder name instead of the correct name is not clear to me. Maybe try a bug report in WSL: https://github.com/microsoft/WSL

driesvints commented 2 months ago

Thanks @Jubeki