Docker Desktop Startup Issue: Container not Running Automatically


I’m facing a puzzling issue and could use some assistance.

I recently set up pi-hole using Docker instructions from GitHub. As pi-hole acts as a DNS server, I want the container to start on system boot or login, allowing me to use it without relying on another server or manually launching the Docker Desktop GUI application.

Currently, the container doesn’t start automatically when I log in, despite configuring Docker to launch on startup:

❯ systemctl list-unit-files --type=service
UNIT FILE                                  STATE           VENDOR PRESET
docker.service                             enabled         enabled     

I’ve also checked the option to allow Docker Desktop to run on login. I believe this corresponds to the autoStart option in the settings file:

❯ cat ~/.docker/desktop/settings.json
  "autoPauseTimedActivitySeconds": 30,
  "autoPauseTimeoutSeconds": 300,
  "autoStart": true,
  "backupData": false,
  "containerTerminal": "integrated",
  "dataFolder": "/home/my_user/.docker/desktop/vms/0/data",
  "deprecatedCgroupv1": false,
  "displayedOnboarding": true,
  "dockerAppLaunchPath": "",
  "dockerBinInstallPath": "system",
  "enableDefaultDockerSocket": true,
  "enhancedContainerIsolation": false,
  "filesharingDirectories": [
  "networkType": "qemu",
  "noWindowsContainers": false,
  "openUIOnStartupDisabled": false,
  "settingsVersion": 35,
  "socksProxyPort": 0,
  "synchronizedDirectories": [],
  "updateHostsFile": false,

Interestingly, when I run a Docker command like:

❯ docker ps -a
Cannot connect to the Docker daemon at unix:///home/my_user/.docker/desktop/docker.sock. Is the docker daemon running?

I’ve noticed that the docker.sock file (under /home/my_user/.docker/desktop/) doesn’t exist until Docker Desktop is launched. However, the /var/run/docker.sock file does exist:

❯ ls -la /var/run/docker.sock
srw-rw---- 1 root docker 0 nov 22 14:01 /var/run/docker.sock

I’ve followed recommended practices for managing Docker permissions by creating a Docker group and adding the user:

❯ grep docker /etc/group

Considering the different .sock files, I looked into Docker contexts:

❯ docker context ls
default        unix:///var/run/docker.sock
desktop-linux* unix:///home/my_user/.docker/desktop/docker.sock

❯ docker context inspect
        "Name": "desktop-linux",
        "Metadata": {
            "Description": "Docker Desktop",
            "otel": {
                "OTEL_EXPORTER_OTLP_ENDPOINT": "unix:///home/my_user/.docker/desktop/otlp-public.grpc.sock"
        "Endpoints": {
            "docker": {
                "Host": "unix:///home/my_user/.docker/desktop/docker.sock",
                "SkipTLSVerify": false
        "TLSMaterial": {},
        "Storage": {
            "MetadataPath": "/home/my_user/.docker/contexts/meta/fe9c6bd7a66301f49ca9b6a70b217107cd1284598bfc254700c989b916da791e",
            "TLSPath": "/home/my_user/.docker/contexts/tls/fe9c6bd7a66301f49ca9b6a70b217107cd1284598bfc254700c989b916da791e"
❯ docker context inspect default
        "Name": "default",
        "Metadata": {},
        "Endpoints": {
            "docker": {
                "Host": "unix:///var/run/docker.sock",
                "SkipTLSVerify": false
        "TLSMaterial": {},
        "Storage": {
            "MetadataPath": "\u003cIN MEMORY\u003e",
            "TLSPath": "\u003cIN MEMORY\u003e"

I aim to have the pi-hole container automatically running on system startup or login. Currently, it only works after manually launching Docker Desktop. How can I resolve this issue?

Thanks in advance!

❯ docker --version
Docker version 24.0.7, build afdd53b

You have to decide whether you want to run Docker Engine (default context) or Docker Desktop (desktop-linux context). The docker group is only for the Docker Engine. Docker Desktop runs on behalf of your user and it is for development where automatically starting is not important. We have discussed it many times, so that’s why my short message. If you want Docker Desktop’s features, you probably have to run it manually. If you want to start containers automatically, that’s a server feature where it is important so you need Docker Engine.

I’m don’t have desktop on Linux, but isn’t Docker Desktop’s systemd service called “docker-desktop” and not just “docker”? As far as I know “docker” is for the engine and in the user-level systemd it is for rootless docker.

1 Like

That did the trick! Your explanation clicks perfectly.

I’ve made the adjustment by spinning up the container under the default context.

After a reboot, I ran a test with an nslookup to an ads domain, and it worked like a charm without needing me to manually launch Docker Desktop.


Yep you are correct, I had no idea about that until now. Configure the daemon with systemd | Docker Docs