Keywords: Docker Daemon | Ubuntu System | Service Configuration | Package Management Conflict | Troubleshooting
Abstract: This article provides an in-depth analysis of Docker daemon startup failures in Ubuntu systems. By examining typical issues such as configuration conflicts and service management confusion encountered in real-world scenarios, and combining Docker official documentation with community best practices, the paper elaborates on Docker package management mechanisms, service configuration principles, and troubleshooting methods. It offers comprehensive solutions including cleaning redundant configurations, properly configuring service parameters, and verifying service status, helping readers fundamentally understand and resolve Docker daemon startup problems.
Problem Background and Phenomenon Analysis
In Ubuntu 14.04 systems, users encountered daemon startup failures after modifying Docker configuration files. Specific manifestations include:
When users followed instructions to add resource limit configurations in the /etc/init/docker.conf file:
limit memlock unlimited unlimited
limit nofile 262144
Subsequent attempts to restart the Docker service prompted that Docker is managed via upstart, suggesting using the service docker restart command. However, executing this command returned:
stop: Unknown job: docker
start: Unknown job: docker
This indicates the system cannot recognize the Docker service job. Even after system reboot, the Docker daemon still fails to start automatically, and manual execution of sudo docker version produces connection errors:
Get http:///var/run/docker.sock/v1.14/version: dial unix /var/run/docker.sock: no such file or directory
This error message clearly indicates the Docker daemon is not running, as the /var/run/docker.sock socket file does not exist.
Root Cause Investigation
Through thorough analysis, we identified that the core issue stems from configuration conflicts caused by multiple Docker package sources in Ubuntu systems.
The user's system contained two configuration files simultaneously:
/etc/init/docker.conf/etc/init/docker.io.conf
And two service entries:
sudo service --status-all |grep docker
docker
docker.io
This duplicate configuration phenomenon originates from different software repositories providing different Docker packages in Ubuntu systems:
- The
docker.iopackage comes from the Ubuntu official repository - The
lxc-dockerpackage comes from the Docker official repositoryhttp://get.docker.io/ubuntu
When systems install Docker packages from different sources simultaneously, configuration conflicts occur, leading to service management confusion.
Solution Implementation
Based on deep understanding of the problem, we propose the following systematic solution:
Step 1: Identify and Clean Redundant Packages
First, identify actually installed Docker packages and remove redundant installations:
# Check installed Docker-related packages
dpkg -l | grep docker
# Remove unnecessary packages based on actual situation
sudo apt-get remove docker.io lxc-docker
Note that package removal may not completely clean configuration files, requiring manual inspection and handling.
Step 2: Manual Configuration Cleanup
If issues persist after package removal, manually clean configuration directories:
# Check and clean Docker configuration files in /etc/init/ directory
ls -la /etc/init/ | grep docker
# Remove redundant configuration files based on actual situation
sudo rm /etc/init/docker.conf
# or
sudo rm /etc/init/docker.io.conf
Keep configuration files corresponding to the currently used Docker package, remove other redundant configurations.
Step 3: Reinstallation and Configuration
After cleanup, reinstall the required Docker package:
# Add Docker official repository (if needed)
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Or install from Ubuntu repository
sudo apt-get update
sudo apt-get install docker.io
Step 4: Service Status Verification
After installation, verify Docker service status:
# Check service status
sudo service docker status
# Start service (if not running)
sudo service docker start
# Enable automatic startup
sudo systemctl enable docker
Technical Principles Deep Analysis
Docker Daemon Management Mechanism
In Ubuntu systems, Docker daemon is typically controlled by system service managers. According to reference documentation, there are two main startup methods:
Using System Utilities: In typical installations, Docker daemon is automatically managed by system utilities, ensuring automatic startup upon system reboot. Specific commands depend on the operating system; on systemd-based systems use:
sudo systemctl start docker
Manual Startup: For testing or special requirements, directly run the dockerd command:
sudo dockerd
In this mode, Docker runs in foreground, logging directly to terminal, facilitating debugging.
Environment Variables and Service Recognition
As shown in supplementary answers, service command execution effects may be influenced by environment variables. Using su - (login shell) versus su (non-login shell) involves different environment variable settings, potentially causing service recognition differences:
# Non-login shell may fail to correctly recognize services
su
service docker status # May fail
# Login shell has complete environment, service recognition normally works
su -
service docker status # Usually succeeds
Best Practice Recommendations
Package Source Selection Strategy
Choose appropriate Docker package sources based on actual requirements:
- Stability Priority: Choose
docker.iopackage from Ubuntu official repository - Update Timeliness: Choose
lxc-dockerpackage from Docker official repository - Avoid Mixed Installation: Ensure only one Docker package source is installed in the system
Configuration Management Standards
When modifying Docker configurations, follow these standards:
- Backup original configuration files before modification
- Confirm correct file paths and belonging packages
- Use correct service management commands after modification
- Verify configuration effectiveness and normal service operation
Troubleshooting Process
When encountering Docker daemon issues, follow this troubleshooting process:
- Check Service Status:
sudo service docker status - Verify Socket File: Check if
/var/run/docker.sockexists - Review System Logs:
sudo journalctl -u docker.service - Inspect Configuration Files: Confirm configuration file completeness and correctness
- Verify Package Installation: Check proper Docker package installation and dependencies
Through systematic analysis and solutions provided in this article, readers should gain deep understanding of Docker daemon management mechanisms in Ubuntu systems and acquire capabilities to resolve similar issues. Proper package management and service configuration are key to ensuring stable Docker operation.