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
CodePudding user response:
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:
- Open a terminal and execute
export DOCKER_HOST={your docker endpoint}
(this is valid only for the current terminal session and you will lose the config on system reboot) - Follow those instructions to set a permanent environment variable (you have to use DOCKER_HOST as a variable name and your own DOCKER ENDPOINT as a value, not the ones used as an example in the answer)
- Open a terminal and execute
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 is docker 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:
- By using an environment variable, as explained above in the TLDR section.
- By passing the host address to the docker-compose command:
docker-compose -H {your docker endpoint} COMMAND