Installing Docker on Ubuntu Linux: A Step-by-Step Guide
Docker is a popular platform for developers to build, deploy, and run applications using containers. Containers provide a consistent and isolated environment for applications, making it easier to deploy and manage applications. In our previous tutorial, you learnt to install docker on Windows Operating System. In this tutorial, we will guide you through the process of installing Docker on Ubuntu Linux.
Prerequisites:
Before you start, make sure you have the following:
- Ubuntu 20.04 LTS or later.
- A user account with sudo privileges.
Step 1: Update the System
Before installing any new software, it’s a good practice to update your system. This ensures that you have the latest security patches and bug fixes. To update your system, run the following commands in the terminal:
sudo apt update
sudo apt upgrade
Step 2: Install Docker CE
Docker provides a Community Edition (CE) that is free to use. To install Docker CE, you need to add the Docker repository to your system. To do this, run the following commands:
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Step 3: Install Docker
Now that the Docker repository is added to your system, you can install Docker. To do this, run the following command:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
Step 4: Start Docker Service
Once the installation is complete, start the Docker service using the following command:
sudo systemctl start docker
Step 5: Verify Docker Installation
To verify that Docker has been installed successfully, run the following command:
sudo docker run hello-world
If the installation was successful, you should see the following output:
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
Step 6: Manage Docker as a Non-Root User
By default, Docker requires you to run the Docker command as root. However, it’s a good security practice to run Docker as a non-root user. To do this, you need to add your user to the Docker group. To add your user to the Docker group, run the following command:
sudo usermod -aG docker $USER
Log out and log back in for the changes to take effect.
Step 7: Configure Docker to Start on Boot
To configure Docker to start automatically on boot, run the following command:
sudo systemctl enable docker
Conclusion
In this tutorial, you learned how to install Docker on an Ubuntu Linux system. Docker is a powerful platform for building, testing, and deploying applications as containers. With Docker, you can easily manage dependencies and deploy applications to different environments. If you encounter any problems during the installation, please consult the Docker documentation for further assistance.