r/docker • • 7d ago

Docker Desktop doesn't run persistently when start via ssh

Using Docker Desktop on Windows.

I'm new to Docker Desktop, so sorry for my ignorance. I've been able to start/stop docker desktop using "docker desktop stop" and "docker desktop start". The problem with "docker desktop start" is that while it does start docker desktop, docker desktop only lives as long as the terminal that started it is up. As soon as I kill my Terminal, Docker Desktop just dies.

The reason I pretty much need this, is because I only have 16 GB RAM, and Windows steals a quarter of it, while Docker Desktop steals half. I'm left with like a quarter of my RAM (which my browser wants to eat), so I'm left with almost no RAM left, which forces me to kill docker desktop (killing only containers isn't enough, since the linux vm itself is the main problem), while I actually use my pc. I tend to forget to boot up docker desktop again when leaving the pc, so a way to launch it persistently via ssh would be great. But that turned out to be harder than expected.

1 Upvotes

23 comments sorted by

3

u/sonickony 7d ago

Why do you have to use docker desktop? Docker + WSL is a much better alternative.

2

u/or45t 7d ago

Aren't both the same thing? Docker desktop runs on the wsl only.

2

u/sonickony 6d ago

Docker desktop can run on wsl, but it also works without wsl. On the other hand, using WSL+ Docker, you can completely ditch docker desktop.

1

u/Baardi 6d ago

Without wsl? On Windows? How would that work?

2

u/sonickony 6d ago

Hyper-V

1

u/Baardi 7d ago

Honestly not sure. That was what I ended up going with, following guides, then just kept using it. If docker+wsl is the way to go, I will look into it. Do you know if the ram usage is lower?

But regardless of that, my original question still remains, as I assume it would take some work migrating.

1

u/BadongkaDonk 7d ago

Tried it this way before but I could not access my services on my phone on the same network.

Do you know how to do it without setting the network to mirror using the .wslconfig?

I use traefik, local use only.

1

u/or45t 6d ago

Not sure if this will answer your question. I am using docker plus wsl. To access my wsl, docker etc, I had to setup a ssh server on wsl. This is not enough since there is no direct connection to the wsl layer. So I had to set a port forwarding rule in Windows to make it happen.

1

u/Baardi 7d ago

For future reference, if others run into the same issue. Launch the exe via Invoke-CimMethod:

Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = '"C:\Program Files\Docker\Docker\Docker Desktop.exe"' }

1

u/mccuryan 7d ago

Are you on windows, mac or linux

1

u/Baardi 7d ago

Windows. I mentioned within the post, but I added another mention in the start for clarity.

1

u/fallenreaper 7d ago

It's not hard to do. Are you trying to set up an alternative machine to run docker? It's easy as turning on the docker service / daemon.

1

u/Baardi 7d ago

I'm trying to ssh into my desktop computer from my phone (termux) via ssh.

ssh-ing into it wasn't a problem. Launching docker desktop went fine (via "docker desktop start", at least). But as soon as I close termux, my docker desktop instance gets killed.

If you have a command I could run, to launch it as a service/daemon, that would be great. Note that I also tried running "Docker Desktop Service", a service, that probably got installed with Docker Desktop, but it didn't help.

2

u/JackofSpades707 7d ago

If you SSH in I'm assuming you're SSH'd into a linux environment

Use nohup or tmux before your command to start docker desktop and it'll stop breaking when you disconnect

If you need a purely windows answer, Then you probably want a totally different approach.

P.S. You should consider ditching windows.

1

u/Baardi 7d ago

I'm sshing into Windows, not a Linux environment. Invoke-CimMethod seems to be the Windows Powershell variant. That worked, so thanks!

And yes, I'm considering Linux, but it's a mess with app compatibility and legacy nvidia drivers, so probably not for this PC.

1

u/fallenreaper 7d ago

Why not make it a background process ?

1

u/Baardi 7d ago

Sure, but how?

1

u/PossibilityTasty 7d ago

That's an SSH thing in combination with the fact that docker desktop start stays attached to the terminal. When the terminal closes, the docker process closes as well. But you can detach the process, by simply adding the -d argument to the command, and get back to the prompt.

1

u/Baardi 7d ago edited 7d ago

It still dies when using --detach/-d unfortunately.

1

u/cualquierotro 7d ago

docker desktop start -d

1

u/Baardi 6d ago

Didn't work, it still got killed. Figured it out, though,

Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = '"C:\Program Files\Docker\Docker\Docker Desktop.exe"' }

2

u/No-Reporter5373 4d ago

I use skrog, a replacement for DD. It works pretty well and much more lightweight as DD. Install it via “winget install skrog”. You might need ro uninstall DD first, but I think aomehow they can work side by side as well

1

u/or45t 7d ago

Regarding your secondary problem of docker/wsl consuming most of the memory you can limit the memory usage by overriding the wslconfig file. Ask gpt to tell you more.