
Installation On Ubuntu in Docker
Install Docker on Ubuntu & Run Containers
If you want to install Docker on Ubuntu and start using it, follow these steps.
Step 1: Update System Packages
First, update the package list to ensure you're installing the latest versions:
sudo apt update && sudo apt upgrade -y
Step 2: Install Required Dependencies
Install some dependencies that help Docker work correctly:
sudo apt install -y ca-certificates curl gnupg
Step 3: Add Docker’s Official GPG Key
sudo install -m 0755 -d /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo tee /etc/apt/keyrings/docker.gpg > /dev/nullsudo chmod a+r /etc/apt/keyrings/docker.gpg
Step 4: Add Docker Repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg]
https://download.docker.com/linux/ubuntu
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Now, update the package list again:
sudo apt update
Step 5: Install Docker Engine
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 6: Start & Enable Docker Service
sudo systemctl start dockersudo systemctl enable docker
Step 7: Verify Docker Installation
Check the installed version:
docker --version
Run a test container to confirm Docker is working:
sudo docker run hello-world
(Optional) Step 8: Run Docker Without sudo
By default, Docker requires sudo
to run. If you want to run it as a regular user:
sudo usermod -aG docker $USER
Then, restart your system:
reboot
After rebooting, check if Docker runs without sudo
:
docker ps
Step 9: Install Docker Compose (Optional)
To install Docker Compose, run:
sudo apt install -y docker-compose-plugin
Verify installation:
docker compose version
🎯 Summary
✅ Installed Docker
✅ Enabled Docker Service
✅ Tested Docker with hello-world
✅ (Optional) Added User to Docker Group
✅ (Optional) Installed Docker Compose