DEV Community

Stanislav Berkov
Stanislav Berkov

Posted on • Edited on

2

Docker in Windows via WSL2, Ubuntu, docker.io

UPDATE 2/24/2025
If you are using WSL2 mirrored networking mode, then install docker-ce instead of docker.io
https://docs.docker.com/engine/install/ubuntu/


If you cannot use Docker Desktop you still can use docker in Windows via Linux and WSL2.

How to:

  • install WSL2,
  • install Ubuntu 22.04,
  • install docker.io in Ubuntu,
  • allow docker remote connection,
  • install Docker CLI in windows,
  • specify DOCKER_HOST.

As a result, you get docker command working in WSL2 and in Windows.

Install Docker

sudo apt update
sudo apt install docker.io

Allow running docker command w/o root

sudo groupadd docker
sudo usermod -aG docker $USER
<reboot> or newgrp docker

Allow docker remote connections

Edit the file /etc/systemd/system/docker.service.d/override.conf by calling the command

systemctl edit docker

Change content to:

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H fd:// --containerd=/run/containerd/containerd.sock
Enter fullscreen mode Exit fullscreen mode

Reload systemd and restart docker

systemctl daemon-reload
systemctl restart docker

Check that port is being listen

netstat -lntp | grep 2375

If not, check the docker logs

journalctl -xeu docker.service

In Windows install docker cli

winget install Docker.DockerCLI

Set environment variable

$env:DOCKER_HOST="tcp://localhost:2375"

You might get docker-credential-wincred not found error

Similar issue is discussed here https://github.com/docker/docker-credential-helpers/issues/24

Edit ~/.docker/config.json file to remove credsStore param.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay