It is very likely that you know or have heard about Docker. This wonder that it is a great solution to software deployment problems. However, it is easy to install. This article will show you how to install Docker on Ubuntu 18.04.
Docker is an open source project designed to automate the large-scale deployment of applications within containers. The idea of doing this is to provide layers of abstraction that allow a program to run regardless of the operating system it runs. So, this is very useful for the sysadmin who manage many different computers.
Combining Docker with ubuntu 18.04 is practically a safe bet for the efficiency and ease of handling of containers.
0. Prerequisites
As you’ll see later, installing Docker on Ubuntu 18.04 is really simple. However, it requires that you have some knowledge about the use of the terminal.
In addition, your user should be able to run commands as root, because it requires installing additional packages and adding repositories.
Finally, it is recommended that you access the server using ssh with strong passwords.
1. Upgrade the system
The first step to install Docker in Ubuntu 18.04, is to update the system. I always recommend doing so because it is necessary to have a robust and secure system and this is obtained by installing the latest security patches issued by the Linux distribution you use, in this case, Ubuntu. So, run this command:
:~$ sudo apt update && sudo apt upgrade
In the end, you will have a more secure system and ready to continue the installation.
2. Add the Docker repository
Docker does not come by default in Ubuntu repositories, therefore, you have to add the particular Docker repository to install it via APT in an easy and secure way. However, first, you need to install some necessary packages.
:~$ sudo apt-get install apt-transport-https ca-certificates curl gnupg software-properties-common
Now add the GPG key from the Docker repository. This is to add even more security to the packages that will be downloaded.
:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Then add the repository in question.
:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Now you can proceed with the installation.
3. Install Docker on Ubuntu 18.04
It’s time to install Docker. Run the following command.
:~$ sudo apt install docker-ce
At the end of the installation. Have the service run at system startup.
:~$ sudo systemctl enable docker :~$ sudo systemctl start docker
To ensure that Docker is fully functional, it is a good idea to check the status of the service.
:~$ sudo systemctl status docker
Finally, look at the Docker Version.
:~$ docker -v
Now that Docker is installed correctly, let’s do the first tests.
4. First steps
Docker has a lot of images for almost everything. It is necessary to look for the one we want, download it and use it. For example, I will look for an image that contains a LAMP server.
:~$ sudo docker search
As you can see in the image, there are several options. Choose the one you want and then download it.
:~$ sudo docker pull nickistre/ubuntu-lamp-wordpress
Now you can use it. If you want to list all the images you have installed. You can do it with this command.
:~$ sudo docker images
5. Run Docker without root privileges
So far you have run Docker as a root user, but this is not advisable. To run Docker without user privileges, run.
:~$ sudo usermod -aG docker $(whoami)
Then restart the computer and it’s done.
Conclusion
Docker is a novel technology and comes in a frank ascent. Many sysadmins see it as an essential part of their work. As you may have noticed, installing Docker on Ubuntu 18.04 is not difficult.
Tell us, have you used Docker? Do you work with Docker?
You can also read “How to install Docker on CentOS 7?“.
Please spread this article through your social networks
before 3 step you have to run this command sudo apt update