S O F T W A R E S P I C E

Loading

how to install docker on ubuntu 18.04

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.

1. Update the System

On Ubuntu Desktop, right-click and open the terminal. We will update the existing list of packages. Run the following command.

sudo apt update
update existing list of packages

2. Install Prerequisite Packages

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. 

install the docker prerequisites

3. Add the GPG Key

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.

add the GPG key

4. Add the Repository

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"
add the docker repository

Since we have added a new repository, run the update command again to update the repository information.

sudo apt update

5. Confirm the Correct Docker Repo

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”.

correct docker repo

6. Install Docker on Ubuntu 18.04

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
install docker on ubuntu 18.04

7. Check Docker Status

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
docker is running on ubuntu 18.04

8. Hello from Docker

It’s just the beginning, we are going to learn a lot about Docker. At the moment, we’ll run a hello-world image from the Docker hub.

hello from docker

9. Configure Docker to start on boot

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

9. How to Check the Docker Version?

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
Version: 20.10.7
API version: 1.41
Go version: go1.13.15
Git commit: f0df350
Built: Wed Jun 2 11:56:40 2021
OS/Arch: linux/amd64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: b0f5bc3
Built: Wed Jun 2 11:54:48 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.6
GitCommit: d71fcd7d8303cbf684402823e425e9dd2e99285d
runc:
Version: 1.0.0-rc95
GitCommit: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
docker-init:
Version: 0.19.0
GitCommit: de40ad0

10. A Quick Summary

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!

Happy Docking!!!

Leave a Comment

Recent Posts

how to stop a docker container
How to Run a Docker Container
How to Push a Docker Image to a Private Repository
How to push a docker image
How to Tag a Docker Image
Software Spice
Share via
Copy link
Powered by Social Snap