This will ensure Docker is installed, configured, and ready to use without common issues. First, update your package list and upgrade existing packages: Install the necessary packages to allow Add Docker’s GPG key to ensure the packages you download are authentic: Add the Docker repository to your APT sources: Update your package list again and install Docker: Check if Docker is running: To run Docker commands without Run the following command to verify Docker works without If you need Docker Compose, install it with:
1. Update Your System
sudo apt update && sudo apt upgrade -y
2. Install Required Dependencies
apt to use repositories over HTTPS:sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
3. Add Docker’s Official GPG Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
4. Add the Docker Repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
5. Install Docker Engine
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
6. Verify Docker Installation
sudo systemctl status docker
sudo systemctl start docker
7. Enable Docker to Start on Boot
sudo systemctl enable docker
8. Add Your User to the Docker Group
sudo, add your user to the docker group:sudo usermod -aG docker $USER
9. Verify Docker Works Without
sudosudo:docker --version
docker run hello-world
hello-world message, Docker is working correctly.
10. (Optional) Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
Troubleshooting Tips
docker group and that you’ve logged out and back in.journalctl -u docker --no-pager -n 50