sail icon indicating copy to clipboard operation
sail copied to clipboard

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

Open MrLarkyy opened this issue 1 year ago • 9 comments

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:

  • run the project with sail
  • stop the project
  • rerun the project with sail
  • now there should be an extra docker container made.

MrLarkyy avatar May 04 '24 16:05 MrLarkyy

What exact commands are you running to reproduce this?

pb30 avatar May 04 '24 17:05 pb30

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

TwqntysJr avatar May 04 '24 17:05 TwqntysJr

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

pb30 avatar May 04 '24 18:05 pb30

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 avatar May 06 '24 15:05 MrLarkyy

image It always creates a new container with random UUID.

image

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

MrLarkyy avatar May 06 '24 15:05 MrLarkyy

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!

github-actions[bot] avatar May 07 '24 12:05 github-actions[bot]

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.

Jubeki avatar May 08 '24 09:05 Jubeki

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.

MrLarkyy avatar May 08 '24 10:05 MrLarkyy

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

Jubeki avatar May 08 '24 10:05 Jubeki

Thanks @Jubeki

driesvints avatar Jun 18 '24 14:06 driesvints