Docker is an open-source platform that simplifies the process of developing, shipping, and running applications inside containers. This guide will cover the installation of Docker on Ubuntu 20.04 and provide an overview of its basic usage.
Prerequisites
- A system running Ubuntu 20.04
- A user account with sudo privileges
- Internet access
Step 1: Update System Packages
Before installing Docker, update the package repository to ensure you have the latest software versions:
sudo apt update && sudo apt upgrade -yStep 2: Install Required Dependencies
Docker requires certain dependencies to be installed. Run the following command to install them:
sudo apt install -y apt-transport-https ca-certificates curl software-properties-commonStep 3: Add Docker’s Official GPG Key
To verify the authenticity of the Docker package, add its GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg |
sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgStep 4: Add the Docker Repository
Add the official Docker repository to your system sources:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]
https://download.docker.com/linux/ubuntu focal stable" |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullStep 5: Install Docker
Update the package list and install Docker Engine:
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.ioStep 6: Verify Docker Installation
Check if Docker is installed correctly by running:
docker --versionTo ensure Docker is running:
sudo systemctl status dockerIf it is not running, start it with:
sudo systemctl start dockerTo enable Docker to start on boot:
sudo systemctl enable dockerStep 7: Run Docker Without Sudo (Optional)
By default, Docker requires sudo privileges. To run it as a non-root user, add your user to the docker group:
sudo usermod -aG docker $USERLog out and log back in for the changes to take effect.
Step 8: Test Docker Installation
Run a test container to verify that Docker is working correctly:
docker run hello-worldIf the installation is successful, you should see a message confirming that Docker is running properly.
Basic Docker Commands
Pull an Image
To download an image from Docker Hub:
docker pull ubuntuList Installed Images
docker imagesRun a Container
To start a container from an image:
docker run -it ubuntu bashThis command runs an Ubuntu container and opens an interactive shell.
List Running Containers
docker psTo see all containers, including stopped ones:
docker ps -aStop a Container
To stop a running container:
docker stop <container_id>Remove a Container
To remove a stopped container:
docker rm <container_id>Remove an Image
To delete an image:
docker rmi <image_id>Clean Up Unused Resources
Remove all stopped containers and unused images:
docker system prune -aConclusion
Docker is a powerful tool that simplifies application deployment and management. This guide covered the installation process and basic commands to help you get started with Docker on Ubuntu 20.04.


