
Installing Docker Community Edition (CE) on Ubuntu 20.04 is a straightforward process that enables you to quickly start building, shipping, and running applications using containers. Follow these steps to get Docker up and running on your system.
First, it is essential to update your existing list of packages and install necessary dependencies. Open your terminal and run:
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
This ensures your package list is current and you have the tools needed to add Docker’s official GPG key and repository.
Next, add Docker’s official GPG key to ensure the downloaded packages are authentic:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Then, set up the stable 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
This command adds the repository information to your system’s sources list.
Now that the repository is added, update the apt
package list again to include the new Docker packages:
sudo apt update
With the updated list, you can install the latest version of Docker Engine, containerd, and Docker Compose:
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
To verify that Docker CE has been installed correctly and is running, you can execute the hello-world
container:
sudo docker run hello-world
If the installation was successful, this command will download a test image and run it in a container, producing a message confirming that your installation appears to be working correctly.
By default, running Docker commands requires sudo
. To run Docker commands as a non-root user, you need to add your user to the docker
group that was created during the installation. Replace <username>
with your actual username:
sudo usermod -aG docker <username>
After adding your user to the group, you must log out and log back in, or restart your system, for the changes to take effect. Alternatively, you can activate the changes for the current session using:
newgrp docker
Once logged back in or after running newgrp docker
, you can run Docker commands without sudo
, for example:
docker run hello-world
Congratulations, you have successfully installed and configured Docker CE on your Ubuntu 20.04 system, ready to start working with containers.
Source: https://kifarunix.com/install-docker-ce-on-ubuntu-20-04/