Hello!
I’m facing a puzzling issue and could use some assistance.
Motivation:
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": [
"/home"
],
"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
docker:x:999:my_user
Considering the different .sock files, I looked into Docker contexts:
❯ docker context ls
NAME DOCKER ENDPOINT
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"
}
}
]
Summary:
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