Docker is the technology of the future that solved all the gaps between developers and system administrators. Developers love Docker because they can build the image of their choice and run it anywhere in the world. Docker Engine installation is pretty simple and quick. Remember when I am talking about installing Docker, I am actually talking about the Docker Engine. It’s the daemon that manages everything. So, in this tutorial, we are going to install Docker on Ubuntu 18.04.
Our system is ready to do that. Those candidates who are willing to learn Docker on Linux from scratch should have prepared a fully functional virtual machine. That’s why earlier, we completed the following prerequisites:
We have had an overview of Docker and completed the prerequisites. Let’s get started with the installation.
On Ubuntu Desktop, right-click and open the terminal. We will update the existing list of packages. Run the following command.
sudo apt update
After updating the system, we need to install a few packages. Its recommended installing these packages to avoid any issues and to make the installation smooth.
Execute the following command:
sudo apt install curl apt-transport-https ca-certificates software-properties-common
The above command installs the packages like curl, apt-transport-https, and software properties. Curl is used to adding the GPG key that we will do in the next step. The other packages are for security helping us to transfer the data and files over HTTPS.
Add the GPG key with the help of the following command:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
The GPG key allows for the secure transmission of information between parties and can be used to verify that the origin of a message is genuine. You should see the following output.
In this step, we will just add the Docker repository to the APT sources. So, when we’ll install Docker, it will get all the dependencies and requirements from that repo.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Since we have added a new repository, run the update command again to update the repository information.
sudo apt update
We are not installing Docker from the default Ubuntu repository, and previously, we added a new Docker repo. In order to make sure that the Docker is being installed from the correct repository, execute the following command.
apt-cache policy docker-ce
You should see the following output. The docker-ce stands for “Docker Community Edition”.
We are all set to install Docker and just one command away. Here’s that gorgeous command to install Docker on Ubuntu 18.04.
sudo apt install docker-ce
Finally, Docker is installed, live and running. We can check the status of the Docker daemon with the help of the following command.
sudo systemctl status docker
The Docker daemon starts on boot by default on Ubuntu and Debian Linux distributions. Therefore, you don’t need to enable it to start on boot. However, if you want to check the behavior and know the command, you can run:
systemctl enable docker.service
To disable Docker on boot, execute the following command
systemctl disable docker.service
Every time your system is booted, you’ll need to start the Docker Engine.
sudo service docker start
We can check the Docker version installed on our Ubuntu machine with the following command:
[email protected]:~$ docker --version
Docker version 20.10.7, build f0df350
Currently, we are running the latest version of Docker.
To get more detailed info, run the command without dashes.
[email protected]:~$ docker version
Client: Docker Engine - Community
API version: 1.41
Go version: go1.13.15
Git commit: f0df350
Built: Wed Jun 2 11:56:40 2021
Server: Docker Engine - Community
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: b0f5bc3
Built: Wed Jun 2 11:54:48 2021
Docker is installed on Ubuntu 18.04 and it is working perfectly fine. The installation is a simple and smooth process. We need to update the system, install the prerequisites and add the GPG key. Furthermore, add the official repository and install Docker from it. Finally, check the Docker status and run some test Docker commands.
If you get the permission denied error while running the docker commands, I have mentioned the quick solution here.
Finally, if you are looking forward to knowing more about Docker, read the following guides.
We’ll move ahead with more adventures on Docker. Stay tuned!