Install Docker on Ubuntu 18.04 (Bionic Beaver) ๐ณ

One of the most beautiful sights to see is a smooth-running development and production environment. Docker makes this a reality with ease ๐. This is one of the main reasons docker usage just skyrocketed in the past couple of years. Well, are you wondering how to get started with installing docker? Look no further, here is a quick tutorial for the most widely used Linux Distro!
Before we start with the installation setups, we will need some prerequisites to be in place. They are:
- Ubuntu 18.04 64 bit Operating System
- A user account with
sudoaccess rights - Though itโs a given, youโll need a terminal to run the installation commands ๐
Step 1 Update repositories
If youโre any familiar with the Ubuntu distro, youโll know that it is always a good idea to update the local repositories before getting started with any software installation process. Hence, just run the following command:
sudo apt-get update
Now, you ahead a get yourself a candy bar ๐ซ and wait to let the process complete.
Step 2 Uninstall Old version of Docker
Since we will be doing a fresh installation of docker, letโs make sure all old installations (or attempts) are removed:
sudo apt-get remove docker docker-engine docker.io
This should be fairly quick. How does your candy bar taste, I bet itโs tasty ๐คค.
Step 3 Install Docker ๐ณ
Letโs use the docker.io repo to install Docker onto the machine:
sudo apt install docker.io
If the command works without any errors, congratulations you have successfully installed docker. Wasnโt it easy!
Step 4 Start Docker service and setup to run on Startup
Now, that the service has been successfully installed. Letโs start the daemon and have it run on startup:
sudo systemctl start docker
sudo systemctl enable docker
Voila! Youโre done and have configured the docker service to run on start up. You can check the service if it is running using systemd:
sudo systemctl status docker
You should see a response like below:
โ docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-04-06 20:47:51 UTC; 4 days ago
Docs: https://docs.docker.com
Main PID: 22527 (dockerd)
Tasks: 49
CGroup: /system.slice/docker.service
โโ 7090 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 15677 -container-ip 172.18.0.2 -container-port 15672
โโ 7102 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5672 -container-ip 172.18.0.2 -container-port 5672
โโ 8104 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 6379 -container-ip 172.19.0.2 -container-port 6379
โโ 9239 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8088 -container-ip 172.20.0.2 -container-port 8081
โโ 9253 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 27717 -container-ip 172.20.0.3 -container-port 27717
โโ22527 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Step 5 Run docker commands without sudo (Optional)
Letโs begin with adding docker group if it doesnโt already exist
sudo groupadd docker
Add the currently connected user $USER to the docker group. If needed, change the username to match the one you prefer
sudo gpasswd -a $USER docker
Also make sure the username is a sudoer
sudo usermod -aG docker $USER
Now you might have to logout and log back for the changes to take affect with a new session.
Step 6 Test by running hello-world docker container
Finally, to make sure everything has been installed and configured correctly, just run the hello-world container
sudo docker run hello-world
Now, you should have the image downloaded to the cache, if it is not already available. You should see the following output on your terminal
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/
Congratulations! ๐ You have docker up and running on your machine. Now go crazy running your docker containers!
Happy Grizzly ๐ป Coding!

Related Posts

How to install OpenVPN using Docker
In this article we will be seeing how easy it is to get started with your own OpenVPN server.

How to create an SSH tarpit
A quick an easy way get back at those obnoxious hacker that target to gain SSH access to your Linux server. This article will show you how to trap the hackers in a SSH tarpit.

How to Use Tee on Linux
Ever wondered how to read from standard input and write results to standard output and files at the same time? Look no further, tee on Linux lets you do just that with no hassle. In this article, we will discuss the basics of tee with some easy to understand examples.