To run the Docker daemon (dockerd) automatically on macOS startup without Docker Desktop, you can use a launchd service (macOS's native service manager). Here's how to set it up:
Step 1: Install Docker (if not already installed)
If you haven't installed Docker Engine (without Docker Desktop), use Homebrew:
brew install docker
Step 2: Create a launchd plist file
-
Open Terminal and create a new .plist file for launchd:
sudo nano /Library/LaunchDaemons/com.docker.daemon.plist
-
Paste the following configuration (adjust paths if needed):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.docker.daemon</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/dockerd</string>
<string>--config-file=/usr/local/etc/docker/daemon.json</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/var/log/docker.log</string>
<key>StandardOutPath</key>
<string>/var/log/docker.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
</dict>
</plist>
- If you need additional flags for
dockerd, add them to the <array> under ProgramArguments.
- If you don't have a
daemon.json file, omit the --config-file line.
-
Save the file (Ctrl+O, then Ctrl+X in nano).
Step 3: Set Permissions
Ensure the .plist file has the correct permissions:
sudo chown root:wheel /Library/LaunchDaemons/com.docker.daemon.plist
sudo chmod 644 /Library/LaunchDaemons/com.docker.daemon.plist
Step 4: Load the Service
Load the service to start it now and enable it for future reboots:
sudo launchctl load /Library/LaunchDaemons/com.docker.daemon.plist
To verify it's running:
sudo launchctl list | grep com.docker.daemon
Step 5: Test Docker
Check if the Docker daemon is running:
docker info
If you see output, the daemon is working.
Optional: Configure docker.sock Access
By default, dockerd runs as root, so regular users can't access the Docker socket. To fix this:
- Create a
docker group:
sudo dseditgroup -o create docker
- Add your user to the group:
sudo dseditgroup -o edit -a $(whoami) -t user docker
- Update the
daemon.json file (create it if missing):
echo '{"group": "docker"}' | sudo tee /usr/local/etc/docker/daemon.json
- Restart the daemon:
sudo launchctl unload /Library/LaunchDaemons/com.docker.daemon.plist
sudo launchctl load /Library/LaunchDaemons/com.docker.daemon.plist
Troubleshooting
- Check logs for errors:
cat /var/log/docker.log
- If Docker commands fail, ensure your user is in the
docker group and restart your shell.
This method ensures dockerd starts at boot without Docker Desktop. Let me know if you need further adjustments!