Skip to main content

Installing Docker

This guide provides step-by-step instructions for installing Docker on Ubuntu and Debian systems using the package manager.

Prerequisites

  • A system running Ubuntu or Debian
  • A user account with sudo privileges
  • Terminal access

Installation Steps

1. Update Package Index

First, update your system's package index:

sudo apt update

2. Install Docker

Install Docker using the package manager:

sudo apt install -y docker.io

3. Start and Enable Docker

Start the Docker service and enable it to start on boot:

sudo systemctl start docker
sudo systemctl enable docker

4. Verify Installation

Check if Docker is installed correctly:

docker --version

5. Configure User Permissions

Add your user to the docker group to run Docker without sudo:

sudo usermod -aG docker $USER

Note: You'll need to log out and back in for this change to take effect.

6. Test Docker

Verify Docker works by running a test container:

docker run hello-world

Post-Installation Steps

Check Docker Service Status

sudo systemctl status docker

Basic Docker Commands

# List running containers
docker ps

# List all containers (including stopped)
docker ps -a

# List downloaded images
docker images

Uninstalling Docker

If you need to remove Docker:

# Stop the Docker service
sudo systemctl stop docker

# Remove Docker and related packages
sudo apt remove --purge docker.io docker-compose
sudo apt autoremove -y

# Remove Docker data and configurations
sudo rm -rf /var/lib/docker
sudo rm -rf /etc/docker

Troubleshooting

Common Issues and Solutions

  1. Permission Denied
# If you get a permission error, ensure your user is in the docker group
groups
# If docker is not listed, run:
sudo usermod -aG docker $USER
# Then log out and back in
  1. Service Won't Start
# Check Docker service logs
sudo journalctl -u docker.service
  1. Network Issues
# Restart Docker service
sudo systemctl restart docker

System Requirements

  • Ubuntu 18.04 or later / Debian 10 or later
  • 64-bit operating system
  • Kernel version 3.10 or higher
  • RAM: 2GB minimum recommended
  • Storage: Varies based on usage

Additional Resources

  • Check system compatibility: uname -a
  • View Docker system info: docker info
  • Docker service logs: sudo journalctl -fu docker

For more detailed information about Docker usage and configuration, visit the official Docker documentation.