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.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

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

Okay