Cannot start Docker daemon using systemctl

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.