docker command not found even though installed with apt-get
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
When you install Docker using apt-get on a Linux system and encounter the "command not found" error, it can be puzzling, especially when the installation process appears to have completed successfully. This error can arise due to various issues, from incorrect PATH settings to incomplete installation. This article explains the possible causes and solutions to the "docker: command not found" error after installation with apt-get.
Understanding the Installation Process
Before diving into troubleshooting, it's crucial to understand how Docker is generally installed on a Linux system using apt-get. Here’s a typical command sequence for installing Docker:
After these steps, Docker should be installed, and you should be able to check its status or version with the following command:
However, if you receive a "command not found" error, something has gone awry.
Common Causes and Solutions
1. Docker Binary Not in PATH
One of the most common issues is that the Docker binary is installed, but its directory is not included in your system's PATH. The PATH is an environment variable specifying directories where executables are located.
Solution:
Add Docker's installation directory to your PATH. This directory is typically /usr/bin/ or /usr/local/bin/. You can edit your shell configuration file (e.g., ~/.bashrc or ~/.bash_profile) to include this directory:
After adding the line, update your shell environment:
2. Incorrect Installation
Sometimes, the installation process may not complete successfully, leaving no executables behind. This may happen due to corrupted packages, interrupted connections, or inadequate permissions.
Solution:
- Remove the incomplete installation:
- Clean up residual package data:
- Re-attempt the installation:
3. Insufficient User Privileges
Docker requires root privileges to execute. If Docker is installed but requires elevated permissions, it might not be accessible to a non-root user.
Solution:
Add your user to the "docker" group to enable permission-free usage:
After running this command, log out and back in to update group membership.
4. Service Not Started
Docker uses a service that needs to be running for command execution. Sometimes, the service isn't started automatically, causing the command to fail.
Solution:
Start the Docker service and enable it to run at startup:
Check the status to ensure it’s running:
Key Points Summary
| Issue | Description | Solution |
| PATH Variable | Docker binary not located within PATH. | Add /usr/bin to PATH in your shell config. |
| Corrupt Installation | Installation was interrupted or incomplete. | Remove, clean, and reinstall Docker using apt-get. |
| Permissions | Docker requires root, and user lacks permissions. | Add user to Docker group. |
| Docker Service Not Running | Docker's service isn't started, preventing command execution. | Start and enable Docker service with systemctl. |
Additional Details
Verifying Docker Installation
If you've followed these steps and still face issues, verify the installation directories manually. Check if Docker binaries are present in /usr/bin/ and /usr/local/bin/. If files are missing, it may hint towards a deeper issue with package management.
Exploring Logs
Review Docker’s logs for any errors or warnings during installation using:
Logs might provide insights into what went wrong during or after installation.
Using Alternative Installation Methods
If issues persist with apt-get, consider installing Docker using alternative methods like the Docker-CE package from Docker's official repository or using Snap packages.
By systematically troubleshooting and addressing these root causes, you can resolve the "docker command not found" issue and ensure a seamless development experience with Docker.

