How to install docker on ubuntu 18.04
If you are having any issues while installing Docker on your Ubuntu operating system, or if you are installing docker for the first time on Ubuntu. Then read the full article as it may help you to install it. Well before moving to the steps on how to install docker in Ubuntu, let’s first see what are containers, Docker and why it has become so popular.
What are containers?
You must be thinking why we are reading about containers. Well the answer is its hard to explain about docker if you don’t know what are containers. Over the past few years a new technology has been introduced known as containers and docker.
These are a new way of running software and allows the developers to build, secure apps and manage them. In simple terms a container is a process that is kept isolated from the other processes in an operating system.
The containers are given some resources which cannot be accessed by any other process. A container which is fully functional cannot access the other resources apart from its resource sandbox. Some advantages of containers are:
- If two containers are present in the same operating system then they are isolated with each other.
- Once you have built and containerized an application then its deployment can take place in any environment on any operating system.
- An application that is containerized can run same and does not depends on the deployment environment.
Docker in simple terms is a platform that packages the application along with its dependencies in the form of containers. This also ensures that the application should work in any environment without any problem.
Why docker has become so popular?
Now that you have seen about containers and dockers, let’s see what makes docker so popular:
- Easy to use: One of the most common reasons of docker’s popularity is its ease. You can learn docker quickly and easily as their are many resources available on how to manage and create containers. Since docker is an open-source service therefore the only requirements are an operating system that can support Virtualbox, docker.
- Docker provides a better software delivery: Since containers are portable therefore software delivery using containers can be very efficient.
The containers have an isolated disk volume which goes along with the container as it is deployed to the various environments. If a container is working on your system then it will run in the same way in the staging, development and the production environment.
Let’s see how to install docker on Ubuntu 18.04
Before moving to the steps of installing docker on Ubuntu, have a look at the prerequisites:
- A 64-bit Ubuntu 18.04 operating system
- You will need an account with sudo privileges.
It may happen that the docker installation package that is available in the Ubuntu 18.04 repository may not be the latest version. So to make sure that the docker version we will install is the latest, we will be installing it from the official docker repository. So firstly start by installing the dependencies and updating the packaging list which are necessary to add a new repository. Type the following command in your terminal.
$ sudo apt update
$ sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Now with the command given below you need to import the GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
The next move is to add the docker APT repository in your Ubuntu system, write the following command to do so:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu(lsb_release -cs) stable"Also check 7 Best download manager Ubuntu / Linux
Now that you have enabled the docker repository on your Ubuntu 18.04, you can install the latest version or any specific version of Docker that you want.
If you want to install the latest version of docker in your Ubuntu 18.04 write the commands given below:
$ sudo apt update
$ sudo apt install docker-ce
This will install the latest version of Docker on your system.
Now if you want to install any specific version of Docker then you need to write the following commands on your terminal:
$ apt list -a docker-ce
Installing a specific version of Docker
So lets say you want to the install the 18.09.7 version of Docker then you have to write:
$ sudo apt install docker-ce=5:18.09.6~3-0~ubuntu-bionic
After writing this command and hitting enter, the installation will begin and once the installation is done the docker service will start automatically. You can also verify it by writing the following command:
$ sudo systemctl status docker
It will show an output something like this:
Till now we have seen the process to install Docker in Ubuntu 18.04 operating system. Now by default managing the docker requires the administrator privileges. If you have to run the commands of Docker as a non-root user then you are required to add your user to the docker group. Well don’t worry you wont have to install any other software or service for doing so. The group is automatically created during the installation process when you have installed the Docker CE package. Run the command given below to do so:
$ sudo usermod -aG docker $USER
The word $USER is the environment variable which is responsible to hold the username. Once the process is complete you can verify it by typing a simple command:
$ docker container run this_is_working
Once the command is executed you will see a message, the command given above it will start downloading a test image and will run it in a container.Label Understanding Cat Command like cat
If you want to uninstall Docker from your system you have to just write the two commands given below:
$ sudo apt purge docker-ce $ sudo apt autoremove
After reading the complete article you must have gained some knowledge about Dockers and containers and how they can be helpful for your projects. Well, Docker is an amazing technology that is very useful to run applications without any problem. With the steps given above you can easily install Docker on Ubuntu 18.04 operating system.