Black Friday Hosting Deals: 69% Off + Free Migration: Grab the Deal Grab It Now!
Installing Docker on Ubuntu 20.04 is an uncomplicated process. It allows you to implement containerization technology for your applications. Docker enables applications to operate safely within a container containing required dependencies and libraries.
Ensure your system meets these requirements
- Ubuntu 20.04 is set up and operating.
- A user account with sudo privileges.
- Access to the terminal or command line.
Updating your system to the latest version of packages and repositories is beneficial. Start a command line interface and execute the provided commands:
sudo apt update
sudo apt upgrade
This guarantees that your system is current and prepared for Docker installation.
Docker requires some prerequisite packages to be installed. These packages are necessary for adding a new repository over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add its official GPG key to your system. It verifies the authenticity of Docker packages.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Afterward, include the Docker repository in your APT 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/null
After adding the Docker repository, update your package database again to include the Docker packages from the new repository:
sudo apt update
Now you can install Docker using the following command:
sudo apt install docker-ce
The docker-ce package includes Docker Engine, the Docker CLI, and containerd. Confirm the installation by checking the Docker version:
docker --version
You should see an output like Docker version 20.10.7, build f0df350.
By default, Docker requires root privileges.
For a non-root user to execute Docker commands, they should be added to the group:
sudo usermod -aG docker $USER
After executing this command, log off sign in to see if the changes take effect. Verify that your user can run Docker commands without sudo:
docker run hello-world
This instruction downloads a sample image and executes it within a container. If the installation is completed successfully, a message will appear to confirm that Docker is functioning properly.
To ensure that Docker starts automatically at boot time, enable the Docker service:
sudo systemctl enable docker
You can use Docker to run containers when it is installed and running. For example, to run an Ubuntu container, use the following command:
docker run -it ubuntu
This command pulls the latest Ubuntu image from Docker Hub and starts a container in interactive mode with a terminal session.
Here are some fundamental Docker commands to assist you get started:
- List Docker images:
- List running containers:
docker ps
- Stop a running container:
docker stop
- Remove a container:
docker rm
- Remove an image:
docker rmi
Setting up Docker on Ubuntu 20.04 requires updating the system, installing essential packages, adding Docker's GPG key and repository, and finally installing Docker. Using this step-by-step tutorial, you will have Docker installed and working on your Ubuntu machine, all set to handle containers for your apps.
Docker makes it easier to deploy applications by bundling them with their dependencies, guaranteeing consistent and reliable performance in various environments. With Docker installed, you can utilize its robust features and tools to improve your development and deployment processes.
Let’s talk about the future, and make it happen!
By continuing to use and navigate this website, you are agreeing to the use of cookies.
Find out more