Cannot start Docker daemon using systemctl in WSL2

I am using WSL Ubuntu to attempt to start docker, but I cannot get it started. The following is the command that I ran to attempt to start docker:

sudo systemctl start docker

There was no message saying that it started. Is there something else I need to do to start docker?

Here is the result after running the above command and then running “docker info” as the super user:

sudo docker info
Client: Docker Engine - Community
 Version:    24.0.7
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.21.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info

Did you enable Systemd in WSL2? I would try

service docker start

The following gives the same result.

sudo service docker start
sudo docker -D info
 wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu                 Running         2
  docker-desktop         Stopped         2
  docker-desktop-data    Stopped         2

Wait, you have Docker Desktop too. Did you install Docker CE in Ubuntu distribution as well or do you just want to use Docker Desktop from the Ubuntu distribution?

If you installed Docker CE in the Ubuntu distribution, how did you do that?

Yes, I installed Docker in Ubuntu, which is what I want to do. Install:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
containerd.io is already the newest version (1.6.26-1).
docker-buildx-plugin is already the newest version (0.11.2-1~ubuntu.22.04~jammy).
docker-ce-cli is already the newest version (5:24.0.7-1~ubuntu.22.04~jammy).
docker-ce is already the newest version (5:24.0.7-1~ubuntu.22.04~jammy).
docker-compose-plugin is already the newest version (2.21.0-1~ubuntu.22.04~jammy).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
[Redacted]:~$ sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

Try to run Docker manually for debugging:

dockerd

Then open another terminal, log in to the distro and try the docker command if dockerd didn’t fail.

You could also check the system logs in /var/log, but I don’t remember where it should be there when systemd is not enabled.

Alternatively, you can enable systemd by adding the following content to /etc/wsl.conf

[boot]
systemd=true

Then restart the distribution. Then you should probably reinstall Docker as well to work with systemd

I reinstalled docker using all of the steps in the following link:

That worked! Thank for your encouragement that helped me though this.

how does to install on arch, i want the new one i just following Arch | Docker Docs these instruction and i got
docker
fish: Unknown command. ‘/usr/local/bin/docker’ exists but is not an executable file. i’m using arch linux distribution anyway garuda OS
please help

This topic is about Docker-CE on a WSL2 Ubuntu distribution.

Sine neither an official WSL2 Arch Linux distribution exists, nor an officially supported Docker-CE package on Arch Linux, how is your situation related to this topic?

Odd. I followed exactly the same steps in the link, and I’m having the same issues as you posted BEFORE you followed the steps in the link.

Did you enable systemd and use sudo docker to run your commands?

Here is the actual issue which doesn’t seem to be related to WSL at all: