How to Install Docker on Ubuntu 18.04

07 July 2020 | Category : Ubuntu

How to Install Docker on Ubuntu 18.04

What is Docker?

Docker is an open-source virtualization tool which that allows creating/build, test, and deploy a containerized platform of the application that can run anywhere. The Docker Container represents a runtime for an application and includes everything the software, package, and library needs to run. In the previous section, we explain How to Install Vagrant on Ubuntu 18.04 in there we explain about Virtualization tools use vagrant, so right here we will explain another tool virtualization which uses Docker.
Docker has two versions which are Community Edition (CE) and Enterprise Edition (EE), in here we will use Community Edition (CE). Unlike the vagrant where require a full-blown operating system to make it run, docker doesn’t need a full-blown operating system, docker just needs some package or library are needed to make it run. Let’s begin to start How to install Docker on Ubuntu 18.04

Install Docker on Ubuntu 18.04

To install Docker on Ubuntu 18.04 it’s easy, you just adding the repository Docker, import the GPG key, and install the Docker. Follow this step to install Docker on your local environment.

Before we begin to step installation you must update and install the dependency first. To do that you can follow this command :

sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common

1. Add repository and GPG Key

After installing the dependency you can add the Docker repository with the GPG key of the repository with this command :

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"

2. Install Docker

And then if the repository was added you can update the list repository and verify the repository list with the command :

sudo apt update
sudo apt list -a docker-ce

Next, to run the command installation of docker you can follow this command

sudo apt install -y docker-ce

3. Verify Installation

When the installation successfully you can verify the installation with check version or run simple docker run command. To do that you can follow this command :

docker --version

That command will show a message like this :

docker --version
Docker version 19.03.12, build 48a66213fe 

Another command to check the installation is running a command :

docker container run hello-world

The command will be showing a message like this :

docker container run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:d58e752213a51785838f9eed2b7a498ffa1cb3aa7f946dda11af39286c3db9a9
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
   (amd64)
3. The Docker daemon created a new container from that image which runs the
   executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
   to your terminal.

   To try something more ambitious, you can run an Ubuntu container with:
   $ docker run -it ubuntu bash

   Share images, automate workflows, and more with a free Docker ID:
   https://hub.docker.com/

   For more examples and ideas, visit:
   https://docs.docker.com/get-started/

4. Execute Docker as Non-Root User

If you want running docker as a non-root user, you can add your user to a group user of docker. To do that you can follow this command :

sudo usermod -aG docker $USER

Note: $USER you can change into your local environment user.

Conclusion

Docker is a command tool deployment for DevOps and Developer, this command has function virtualization which allowing to create/build, test, and deploy a containerized platform. Unlike Vagrant, Docker doesn’t need a full-blown operating system to make it run. In this article, you just learn How to Install Docker on Ubuntu 18.04

Share this article :