Skip to content

Conversation

gajeshbhat
Copy link

Summary

This PR adds a new --start-daemon command-line option that automatically starts and enables the Docker daemon service after installation, addressing issue #124.

Problem

It would be useful to have an option to automatically start the Docker daemon after installation, noting that service management differs between distributions like CentOS and Ubuntu. Currently, users must manually run sudo systemctl start docker and sudo systemctl enable docker after installation.

Solution

Added a --start-daemon flag that:

  • Detects the available service management system (systemd vs traditional)
  • Uses appropriate commands for each system:
    • systemd: systemctl start docker && systemctl enable docker
    • Traditional: service docker start && chkconfig docker on (or update-rc.d)
  • Only starts the daemon when explicitly requested (safe by default)
  • Supports --dry-run to show what commands would be executed
  • Works across all supported distributions

Usage

# Install Docker and start the daemon
sudo sh install.sh --start-daemon

# See what would happen (dry-run)
sudo sh install.sh --start-daemon --dry-run

Testing

Thoroughly tested across all supported distributions:

  • Ubuntu (20.04, 22.04, 24.04)
  • Debian (11, 12)
  • CentOS Stream (8, 9)
  • Fedora (40, 41)
  • RHEL/AlmaLinux (8, 9)

Add a new --start-daemon command-line option that automatically starts
and enables the Docker daemon service after installation. This addresses
the cross-platform service management differences between distributions
like CentOS and Ubuntu mentioned in issue docker#124.

Features:
- Detects systemd availability and uses appropriate service commands
- Uses systemctl start/enable on systemd systems
- Falls back to service/chkconfig on non-systemd systems
- Supports --dry-run to show what commands would be executed
- Only starts daemon when explicitly requested via --start-daemon flag
- Works across all supported distributions (Ubuntu, Debian, CentOS, RHEL, Fedora)

The implementation is safe by default - the daemon is only started when
the user explicitly requests it, maintaining backward compatibility.

Fixes docker#124

Signed-off-by: Gajesh Bhat <[email protected]>
@gajeshbhat gajeshbhat force-pushed the feature/daemon-start-option branch from b8ecd36 to b99efe2 Compare August 7, 2025 04:08
@gajeshbhat
Copy link
Author

@thaJeztah Can you kindly take a look ? Do you think the feature would be useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant