DEV Community

How to run docker on Windows without Docker Desktop

Nicolas Louis on September 26, 2021

Since Docker announced a new subscription for Docker Desktop for personal use, educational institutions, non-commercial open-source projects and s...
Collapse
 
dlvoy profile image
Dominik Dzienia

For me launching dockerd failed since chain of commands with ifconfig returned some extra garbage.

I was able to fix it with adding | head -n 1 at the end, so final command would look like:

sudo dockerd -H `ifconfig eth0 | grep -E "([0-9]{1,3}.){3}[0-9]{1,3}" | grep -v 127.0.0.1 |awk '{ print $2 }' | cut -f2 -d: | head -n 1`
Enter fullscreen mode Exit fullscreen mode
Collapse
 
patrickleboutillier profile image
Patrick LeBoutillier

You need to escape the dot (.) in the regexp as such:

"([0-9]{1,3}[.]){3}[0-9]{1,3}"

Then it will work as expected.

Collapse
 
pawelgnatowski profile image
Pawel Gnatowski

Would you be interested in how to do same without so much trickery?
Ip stuff port forwarding etc. I mean?
My simple repo can have you up and running. I will write an article eventually, but it is there.

Collapse
 
_nicolas_louis_ profile image
Nicolas Louis

Hi Pawel, thank you for your feedback. I tried to made some simplifications from the initial article from Jonathan Bowman. I had in mind to make my existing toolchains still working (VSCode, Visual Studio).
I'm very interested if you have a simpler way to proceed :)

Collapse
 
pawelgnatowski profile image
Pawel Gnatowski

I run this stack using this. Start of the month i will write full article, for now this will have to do.
Essentially i run docker, vs code , gpu compute (inside containers too) all on ubuntu wsl2. With proper networking, which is the biggest blunder from M$ to date in regard to wsl..
github.com/pawelgnatowski/WSL2-Net...

Collapse
 
herbatnik profile image
Marek Kreśnicki

Exactly my thoughts, there's too much complexity here + there's more comprehensive guide on how to install docker in Linux on official docker website which takes half of this article.

Collapse
 
jaipsharma profile image
Jai Prakash Sharma

I followed all the steps but unable to run docker on my WSL2 -

Any help in debuggin -

sudo dockerd -H ifconfig eth0 | grep -E "([0-9]{1,3}.){3}[0-9]{1,3}" | grep -v 127.
0.0.1 |awk '{ print $2 }' | cut -f2 -d:

[sudo] password for jai:
INFO[2021-11-06T15:39:08.506977000+05:30] Starting up
WARN[2021-11-06T15:39:08.509171500+05:30] Binding to IP address without --tlsverify is insecure and gives root access on this machine to everyone who has access to your network. host="tcp://169.254.255.121:2375"
WARN[2021-11-06T15:39:08.509628200+05:30] Binding to an IP address, even on localhost, can also give access to scripts run in a browser. Be safe out there! host="tcp://169.254.255.121:2375"
WARN[2021-11-06T15:39:10.291048100+05:30] Binding to an IP address without --tlsverify is deprecated. Startup is intentionally being slowed down to show this message host="tcp://169.254.255.121:2375"
WARN[2021-11-06T15:39:10.292307700+05:30] Please consider generating tls certificates with client validation to prevent exposing unauthenticated root access to your network host="tcp://169.254.255.121:2375"
WARN[2021-11-06T15:39:10.292918800+05:30] You can override this by explicitly specifying '--tls=false' or '--tlsverify=false' host="tcp://169.254.255.121:2375"
WARN[2021-11-06T15:39:10.294801200+05:30] Support for listening on TCP without authentication or explicit intent to run without authentication will be removed in the next release host="tcp://169.254.255.121:2375"
failed to load listeners: listen tcp 169.254.255.121:2375: bind: cannot assign requested address

jai@FA057586:~$ wsl
WSL
Wsman Shell commandLine, version 0.2.1

Collapse
 
nelsonpena profile image
Nelson Peña

I had the same error, it seems it's because you are using WSL version 1. Just run wsl --set-default-version 2, and re install your linux distribution.

Collapse
 
jvmlet profile image
Furer Alexander

Thanks Nicolas. Have you managed to mount volumes from windows to docker image running in WSL2 ? Looks like windows folder has to be mounted first to WLS2 and then from WSL2 to the docker image ....

Collapse
 
_nicolas_louis_ profile image
Nicolas Louis

When windows folders are mounted and you launch a terminal to your WSL2 distro, you can navigate on your windows folders with commands like : wsl cd MyWindowsDirectory... wsl ls etc... without to be connected to a bash, just direcly from windows :)
When Dockerd is simply launched in your distro, you can run also "wsl docker ps" etc...

Collapse
 
herbatnik profile image
Marek Kreśnicki

It's easy, by default (at least for me) wsl has mounted all drives in /mnt// for example /mnt/c/ for C: Drive and /mnt/d/ for D: drive
From there you can simply use these paths as youve mentioned

Collapse
 
jvmlet profile image
Furer Alexander

yes, you are right... but.
Previously with Docker Desktop we could run docker with -v %cd%/someFolder:/whatever or -v ./someFolder:/whatever, now we have to provide full path , like -v /mnt/c/full/local/path/to/someFolder:/whatever , which is user specific and will not run on team mate's computer... Any thoughts how to overcome this ?

Collapse
 
byteskater profile image
Christopher Lutat

Thanks for the article, I was able to successfully implement most of it.

I am stuck here trying to start dockerd from the Windows PowerShell (in admin mode):
PS C:\Users\clutat> wsl sh -c "sudo dockerd -H tcp://$ip"
sudo: dockerd: command not found

Any ideas what's incorrect here?

Collapse
 
petrysko profile image
Petrysko • Edited

Hi guys,

I am receiving error at launch docker with

sudo dockerd -H ifconfig eth0 | grep -E "([0-9]{1,3}.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d:

The error is: failed to start daemon: pid file found, ensure docker is not running or delete /var/run/docker.pid

I tried deleting pid file but i dont have permission for it i tried using sudo systemctl stop docker and then running it but error is still the same.

Can anyone help me with it please ?

Thank you
`

Collapse
 
maihoang626 profile image
maihoang626

sudo dockerd -H ifconfig eth0 | grep -E "([0-9]{1,3}.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d:

above command in "Launch dockerd" section shows this error : "dockerd" accepts no argument(s)

Collapse
 
pvlerick profile image
Philippe Vlérick

Hello, there is a small error in regex provided to get the host's IP address; if the output of ifconfig eth0 returns this:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.109.90  netmask 255.255.240.0  broadcast 172.17.111.255
        inet6 fe80::215:5dff:fe3a:5592  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:3a:55:92  txqueuelen 1000  (Ethernet)
        RX packets 4570  bytes 2075002 (2.0 MB)
        RX errors 0  dropped 3  overruns 0  frame 0
        TX packets 238  bytes 26662 (26.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Enter fullscreen mode Exit fullscreen mode

it will match the line starting with "TX packets too".

Here is the corrected version: ifconfig eth0 | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d:

Collapse
 
praveengmail1 profile image
praveengmail

Hello,

I am trying to follow the above steps on Alpine and i am not able to figure out the equivalent for launching dockerd to get the ip address.

Below one works fine in ubantu
sudo dockerd -H ifconfig eth0 | grep -E "([0-9]{1,3}.){3}[0-9]{1,3}" | grep -v 127.0.0.1 |awk '{ print $2 }' | cut -f2 -d:

Any idea/Help?

Best Regards,

Praveen

Collapse
 
praveengmail1 profile image
praveengmail

Hello,

Does anybody has a equivalent command for Alpine?

Praveen

Collapse
 
zalithka profile image
Andre Greeff

so.. my morning started out heading towards this rabbit-hole, but then fortunately I checked with our HR department, and discovered that my employer doesn't exceed the requirements for a commercial Docker Desktop license. big relief for me right there..

while this post does contain lots of super technical points (yeah, I saw those comments), this is a super technical topic.. which leads straight back to the "how" and "why" of Docker's decision on this matter.

anyways, with the deadline for this looming ever closer, I suspect there are going to be a sudden stupendous influx of "Docker alternative" and "Docker without Docker Desktop" articles, debates, and so on.. not unlike this one.

so before that gets out of control: I'd like to share one that I did discover just this morning: devopstales.github.io/home/docker-...

it has lots of helpful information presented in a clear way, and the alternatives it lists don't require any "special magic" to get working, which might be very appealing for some.


with all that said: I do sincerely hope that anyone able and/or required to pay for a license actually does so... it would be really sad for Docker to have come this far, having influenced so many aspects of "containerization", only to fade into the background because of "suddenly not being free to everybody". at the end of the day, everybody still has bills to pay.. 🤔

Collapse
 
altanmehmet profile image
Altan Mehmet Türkmen

I got this error when I tried to run "sudo dockerd -H ifconfig eth0 | grep -E "([0-9]{1,3}.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d:" And I can't see my eth0 configs in ifconfig command
error:failed to load listeners: listen tcp 169.254.218.38:2375: bind: cannot assign requested address
Thanks for the help.

Collapse
 
muttsuri profile image
Muttsuri

Have you heard of portainer? It's a Web based docker ui.

I don't have a complex use case for it but I think it works.

There is some socket magic that I don't know by memory because I just keep the command in a gist.

I'll share later in a response to this comment

Collapse
 
_nicolas_louis_ profile image
Nicolas Louis

Hi Muttsuri, Yes I use Portainer to manage containers and stacks on server.
My concern was to continue to debug from Visual Studio 2019 and Visual Code directly in container.

Collapse
 
_nicolas_louis_ profile image
Nicolas Louis

Hi, you can use the variable DOCKER_HOST to specify the way you want to connect to docked : unix://, tcp://, ssh://

Collapse
 
inuski profile image
inuski • Edited

Hello, thank you for this article. I've been reading both this and "Install Docker on Windows (WSL) without Docker Desktop". At the moment I am stuck at step Launch dockerd and I get this error (image below).

ibb.co/yQGVZ18
I set that host path in that previous tutorial in the daemon.json file. I am a bit confused on how to solve this because Im very new to this, so I would appreciate any help. Thanks!

Collapse
 
arm1 profile image
Armand Paghent

You have to remove the daemon.json if you want to use args command line.

Collapse
 
hanokhaloni profile image
Hanokh Aloni

Looks too much tricky for me. I would prefer a prettier straight-foreward solution.

I really liked how your turned windows into a linux by adding a c:\bin dir :)

Collapse
 
alexei000 profile image
Alex Dragan • Edited

Rancher Desktop seems to simplify things a lot for Windows users:

  • installs docker & friends.
  • configures its own guest (rancher-desktop)
Collapse
 
regifraga profile image
Regivaldo Fraga do Nascimento

Great man, thks a lot... you save my day!!!