How to configure Docker Desktop to start on boot via cli?

I have a script which configures my system to boot without GNOME, and I’d like to add additional commands to configure docker desktop to start automatically.

The post-installation guide for the docker engine (not docker desktop) has the following steps listed:

To enable start on boot:
sudo systemctl enable docker.service
sudo systemctl enable containerd.service

To disable:
sudo systemctl disable docker.service
sudo systemctl disable containerd.service

It’s not surprising that these commands do not work with docker desktop, and I’m having trouble finding any equivalent commands that I should use.

Why do you want to automatically start Docker Desktop on Linux especially without GUI? Docker Desktop is for development, so I don’t the benefit of starting it when there is no user using the GUI. Running Docker containers in the background before any user logs in can be done by using Docker CE.

There is a part in the documentation that mentions systemctl commands with Docker Desktop for each distribution. Here is a link for Ubuntu: Install Docker Desktop on Ubuntu | Docker Docs

That still requires logging in, but running “su - USERNAME” as root should be enough. I don’t know how that works non-interactively, but you need to find a way to keep the user logged in. If the user is root, then I guess you just enable the systemd service, but then it is really not used for development.

I appreciate the link seeing as I must have passed over that portion of the guide.

I have a few reasons for this configuration. I work full time and Proxmox was too time consuming to configure for my home server / remote development workstation. Alternatively Ubuntu with GNOME is fast and easy in comparison, but it needs only to be converted to a server as in this example. Secondly, having the machine configured to work with a headless boot option can make life easier with a single gpu passthrough to a qemu kvm machine. Thirdly, I rely on docker extensions which, as far as I know, are only available to Docker Desktop.

The solution I arrived at involves creating a service which invokes the docker-desktop startup command:

[Unit]
Description=Docker Launcher

[Service]
Type=idle
ExecStart=sudo systemctl --user -M user-name@ start docker-desktop

[Install]
WantedBy=multi-user.target

This service can in-turn be enabled/disabled on demand for a headless boot configuration:

systemctl enable|disable service-name.service
1 Like

Interesting. Thank you for sharing your solution. So you can enable and disable this service but you can’t stop it with systemctl stop service-name.service right? If it was not important then it seems like a good trick.