Docker-Compose Stop Working After Docker Desktop Installation on Debian 11

docker-compose stop working after Docker Desktop installation on Debian 11

EDIT:

Fastest and cleaner way:

Check "Enable Docker Compose V1/V2 compatibility mode" in the General section of the Docker Desktop settings.

TLDR:

  1. Run the command docker context ls to discover the new host.

  2. Copy the DOCKER ENDPOINT corresponding to the desktop-Linux context

  3. 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)

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:

  1. By using an environment variable, as explained above in the TLDR section.
  2. By passing the host address to the docker-compose command: docker-compose -H {your docker endpoint} COMMAND

Why is Docker installed but not Docker Compose?

You also need to install Docker Compose. See the manual. Here are the commands you need to execute

sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)"  -o /usr/local/bin/docker-compose
sudo mv /usr/local/bin/docker-compose /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose

Docker is running. Docker Desktop says Docker Desktop stopped...

I had the same problem on Debian 11 and Docker Desktop 4.8.1

  1. If you are using Linux inside a VM, verify virtualization support. Docker Desktop runs a VM that requires KVM support.

https://docs.docker.com/desktop/linux/install/#kvm-virtualization-support


  1. If you're using VMWare, you need to enable CPU counters.

https://github.com/canonical/multipass/issues/1085


  1. Verify qty with

    egrep -c '(svm|vmx)' /proc/cpuinfo

  2. You need to stop and disable Docker.

    $ sudo service docker stop
    $ sudo systemctl disable docker.service
    $ sudo systemctl disable docker.socket

    Then, restart your linux and your Docker desktop.

    Even more, if you run docker ps as root user , you don't use docker desktop. You have another list of containers.

  3. Be careful if you change "Setting-> Resources-> Advanced: Disk Image location" , you must not delete the default file 1.8G => home/YOUR_USER/.docker/desktop/vms/0/data/Docker.raw

    You can change the path, but you need to keep that file in that location.

Sample Image

Reset factory
Sample Image

Docker desktop restart

Sample Image

Docker service status after reboot my computer

Sample Image

Full history:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo usermod -aG docker YOUR_USER
sudo apt install gnome-terminal
sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager -y
sudo usermod -aG kvm YOUR_USER
sudo apt autoremove
sudo apt install ./docker-desktop-4.8.1-amd64.deb
sudo systemctl disable docker.service
sudo systemctl disable docker.socket

Test VirtualBox VM - Ubuntu 20.04

Sample Image

Docker Desktop error: TLS configuration is invalid (problem with DOCKER_TLS_VERIFY and DOCKER_CERT_PATH )

Solved: I removed DOCKER_TLS_VERIFY and DOCKER_CERT_PATH environment variables. These pointed to deleted configuration. Anyway, I don't need this now.
Furthermore, I couldn't see these environment variables in Docker Desktop PowerShell, thus I could work there. It confused me a bit. I don't know why the Docker Desktop environment is different. In the past I had Docker installation on my machine, maybe this also could cause problems.

How to upgrade docker-compose to latest version

First, remove the old version:

If installed via apt-get

sudo apt-get remove docker-compose

If installed via curl

sudo rm /usr/local/bin/docker-compose

If installed via pip

pip uninstall docker-compose

Then find the newest version on the release page at GitHub or by curling the API and extracting the version from the response using grep or jq (thanks to dragon788, frbl, and Saber Hayati for these improvements):

# curl + grep
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*\d')

# curl + jq
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)

Finally, download to your favorite $PATH-accessible location and set permissions:

DESTINATION=/usr/local/bin/docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION
sudo chmod 755 $DESTINATION

Can't connect to docker from docker-compose

The Docker machine is running. But you need to export some environment to connect to the Docker machine. By default, the docker CLI client is trying to communicate to the daemon using http+unix://var/run/docker.sock (as shown in the error message).

Export the correct environment variables using eval $(docker-machine env dev) and then try again. You can also just run docker-machine env dev to see the environment variables it will export. Notice that one of them is DOCKER_HOST, just as the error message suggests you may need to set.

Docker Compose Up gives The system cannot find the file specified. error

You and I may or may not have the same problem. In the link posted by @Haken Lid above, the issue is with the PATH environment variable not having the correct version of Python.

BUT, for me, the issue was that I had not set all of my environment variables, by running

eval $(docker-machine env <vmname>)

before I ran the docker-compose <any command>.



Related Topics



Leave a reply



Submit