Solution
Just put this in your .env
the following
SAIL_XDEBUG_MODE=develop,debug
SAIL_XDEBUG_CONFIG="client_host=host.docker.internal"
Just as in Windows and MacOS
Now you can run sail debug migrate
or just sail debug
in order to test it.
Explanation
You're probably using sail down
to 'stop' the containers, but as the docker documentation stated:
docker-compose down
...
Stops containers and removes containers, networks, volumes, and images created by up
.
By default, the only things removed are:
- Containers for services defined in the Compose file
- Networks defined in the networks section of the Compose file
- The default network, if one is used
Thus, every time you're running sail up
it will regenerate the network with a new IP address.
You could use sail stop
, but when you're working with multiple projects it could become a hassle to edit the ports (in the .env
file) of every service per project.
As per v1.10.1, sail incorporate the extra_host
option, essentially detecting the IP of the host machine:
With this, every time we create/start the application container the host.docker.internal mapping will be created and will point to the host machine.
Edit: Do not forget to update Docker since this only works with Docker v20.10+.