I installed Docker Desktop for Linux on my Debian 11 machine.
After the installation, I’m not able to use docker-compose or laravel sail.
The error is:
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
The DOCKER_HOST env variable is not set.
The docker CLI is still working properly.
Someone can help me?
Thanks in advance
2
Answers
EDIT:
Fastest and cleaner way:
Check "Enable Docker Compose V1/V2 compatibility mode" in the General section of the Docker Desktop settings.
TLDR:
Run the command
docker context ls
to discover the new host.Copy the DOCKER ENDPOINT corresponding to the desktop-Linux context
Set the DOCKER_HOST environment variable by choosing one of those two methods:
export DOCKER_HOST={your docker endpoint}
(this is valid only for the current terminal session and you will lose the config on system reboot)Long answer and explanation:
The Docker Desktop on Linux runs on a virtual machine and uses docker compose V2 instead of
docker-compose
(the command to use it isdocker compose
without the hyphen).To avoid it masks the docker engine service on the local machine and creates a new context.
As the local Docker service has been masked, it is not running anymore on your local machine.
The context can be switched to the default one if you want to use Docker Engine instead of Docker Desktop. That way your local docker-compose will work as before.
Another way is to connect the local docker-compose to the Docker Desktop host on the new virtual machine.
This can be done in two ways:
docker-compose -H {your docker endpoint} COMMAND
docker context ls
give output
it will work