How to Install & Use Docker on Ubuntu 18.04 LTS Bionic Beaver

Multiple ways to install Docker CE in Ubuntu 18.04

Install Docker on Ubuntu 18.04


ocker For Ubuntu 18.04: Docker is a software application that simplifies the process of managing the application process in the containers. The containers are similar to “Virtual Machines” but containers are portable. This Docker is a most familiar software package developed by the Docker. The benefits of using Docker is that it shares the resources with kernel and makes it easy to process the applications inside the containers. Dockers don’t need any dedicated resources. Docker is available in two versions, they are Docker CE and Docker EE!

Docker CE means Consumer Edition and Docker EE means Enterprise Edition. If you are using this Docker for single user purpose and then we suggest you go with Docker CE. In this article, We clearly explained each important steps to install Docker in Ubuntu 18.04 LTS Bionic Beaver Edition.

Jump To:


You just need the server setup running in Ubuntu 18.04 with superuser authority and Firewall enabled. You just need to uninstall or remove the older versions of Docker from your server. The older versions of Docker are called as docker,, or docker-engine. The below command will remove all the older versions.

$sudo apt-get remove docker docker-engine containerd runc
Remove older versions of Docker
Remove older versions of Docker

It’s OK! if apt-get reports that none of these packages are installed.

Installing Docker Application in Ubuntu 18.04:

There are two ways to install the Docker application in Ubuntu 18.04 server, They are:

Install Docker on Ubuntu using Default Repo:

The first step is updating your system to the current.

$sudo apt-get update

The above command will update your system. Then you need to uninstall the older version of Docker { skip if you followed this step as we mentioned in Prerequisites }.  Then follow the below step to install the Docker application.

Install Docker Application Command:

$sudo apt install

The above command will initiate the installation process of Docker application in your Ubuntu Server.

Initiate & Automate Docker:

By default, The Docker app is not running on startup and so you need to set the application to run in startups.

$sudo systemctl start docker
$sudo systemctl enable docker

That’s it, The Docker application has been installed using default repositories. But we recommended the below method to install the Docker on Ubuntu 18.04. Let us get into the detailed methods for installing this Docker application.

Check this too  {Latest} Configure Static IP Address On Ubuntu 18.04 LTS- How To?

Install Docker from Official Repository:

The Docker package available in the default repository may be an outdated version and so we recommend you use the official Docker repo to install the latest version. Here we explain the detailed steps for installing the Docker app for Ubuntu 18.04

Step1- Update your existing packages:

$sudo apt update

Installation Process:

Now install a few prerequisite packages which let over HTTPS:

$sudo apt install apt-transport-https ca-certificates curl software-properties-common
apt use packages
apt use packages

Then add the GPG key for the official Docker Repository to your system.

$curl -fsSL | sudo apt-key add -
Adding GPG key
Adding GPG key

By executing the above command you will get an output as “OK“, means you are good to go.

Now you need to add the Docker repo to the APT sources:

$sudo add-apt-repository "deb [arch=amd64] bionic stable"
Adding Docker repo to APT
Adding Docker repo to APT

Once it got completed, kindly update all the packages.

$sudo apt update

Now you need to ensure that you are installing the Docker from the official Docker repo instead of Ubuntu repo.

$apt-cache policy docker-ce

The docker-ce means ” Docker Consumer Edition “. Execute the above command and you will get output like below.


Installed: (none)
Candidate: 18.03.1~ce~3-0~ubuntu
Version table:
18.03.1~ce~3-0~ubuntu 500
500 bionic/stable amd64 Packages


From the output, you may able to see that Docker is not installed but the candidate for installation is from the Docker repository for Ubuntu 18.04.

Now all the before steps are completed, Install the Docker Application:

$sudo apt install docker-ce
Installing Docker
Installing Docker

Once the installation has been completed successfully. Kindly enter the below command to check the Docker version.

$docker --version
Docker Version
Docker Version

The above version is the latest version of Docker installed from the official Docker Repo.

Launching the Docker Application:

After the installation process, You need to assign the sudo power to the Docker group. By default, The Docker command can run only by the root admin only. If you try to access the Docker group without “sudo” it will throw you the error. If you are not the member or admin of the Docker group and then it will throw you the error.


docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?. See ‘docker run –help‘.

You can simply avoid this error by calling the docker group with “sudo” command or adding the user has admin privileges to the docker group.

$sudo usermod -aG docker ${USER}

The above command will add you to the Docker group with admin privileges.

Check this too  5+ Ways To Restart Your Apache Server On Ubuntu 18.04, 18.04.2 & 19.04 Disco Dingo

To apply for the new group membership, log out of the server and back in and type the following command.

$su - ${USER}

Then confirm the process that you adding the new user to the Docker group.

$id -nG

Using the Docker Application:

To view all available commands of Docker:

Available Commands in Docker
Available Commands in Docker

As of Docker 18.09 version, the below list of commands is available.

attach - Attach local standard input, output, and error streams to a running container
build - Build an image from a Dockerfile
commit - Create a new image from a container's changes
cp - Copy files/folders between a container and the local filesystem
create - Create a new container
diff - Inspect changes to files or directories on a container's filesystem
events - Get real-time events from the server
exec - Run a command in a running container
export - Export a container's filesystem as a tar archive
history- Show the history of an image
images - List images
import - Import the contents from a tarball to create a filesystem image
info - Display system-wide information
inspect- Return low-level information on Docker objects
kill - Kill one or more running containers
load - Load an image from a tar archive or STDIN
login - Log in to a Docker registry
logout - Log out from a Docker registry
logs - Fetch the logs of a container
pause - Pause all processes within one or more containers
port - List port mappings or a specific mapping for the container
ps - List containers
pull - Pull an image or a repository from a registry
push - Push an image or a repository to a registry
rename - Rename a container
restart- Restart one or more containers
rm - Remove one or more containers
rmi - Remove one or more images
run - Run a command in a new container
save - Save one or more images to a tar archive (streamed to STDOUT by default)
search - Search the Docker Hub for images
start - Start one or more stopped containers
stats - Display a live stream of container(s) resource usage statistics
stop - Stop one or more running containers
tag - Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top - Display the running processes of a container
unpause- Unpause all processes within one or more containers
update - Update configuration of one or more containers
version- Show the Docker version information
wait - Block until one or more containers stop, then print their exit codes

$docker info
The above command will provide overall information {system wide}.

Working with Docker Images:

Docker containers are built from Docker images and by default, Docker pulls the images from the official Dockers hub. These Docker hubs are also managed by the Docker company. The Docker hub allows anyone to host their Docker images.

Check this too  How To Access MYSQL Database Error Log Files Server Side

To check whether you can access from Docker Hub:

$docker run new-world

The following output will appear on your screen:


Unable to find image ‘new-world:latest‘ locally
latest: Pulling from library/new-world
9bb5a5d4561a: Pull complete
Digest: sha256:3e1764d0f546ceac4565547df2ac4907fe46f007ea229fd7ef2718514bcec35d
Status: Downloaded newer image for new-world:latest

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

The output message simply says that Docker was unable to find the new-world image. So it downloaded the image from Docker hub. Once the image has been downloaded, then the application inside the container will execute and the result will be displayed.

Searching for Docker Images:

You can search for Docker images inside the Docker hub with the help of a “search” command.

$docker search ubuntu

The list of Docker images will appear in your screen as shown in below image.

Docker Image Search
Docker Image Search

You can download the Docker images using the “pull” command. The OK represents the image built and supported by Docker hub.

$docker pull ubuntu
The above command will download the Ubuntu image to your computer.

To see the downloaded Docker images in your computer:

$sudo docker images
Downloaded Docker Image
Downloaded Docker Image

 Managing Docker Images:

In this managing area, we will explain you that how to “Stop, Start & Attach

Starting your Docker Container:

$docker start Container_ID

The above command will start your Docker container.

Stoping your Docker Container:

$docker stop Container_ID

The above command will stop your Docker container.

Attaching your Docker Container:

$docker attach Container_ID

The above command will attach your Docker containers.

Uninstalling Docker on Ubuntu 18.04:

To uninstall the Docker application from Ubuntu 18.04, execute the following command:

$sudo apt-get purge docker-ce

Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes execute the following command:

$sudo rm -rf /var/lib/docker

The above command will remove all Docker images, container and volumes. But you must delete any edited configuration files manually.


That’s it. In this article, we clearly explained the information about installing the Docker on Ubuntu 18.04 LTS. You need to follow the installation steps carefully. Docker is the application to manage the process inside the container. If you have any queries and then comment on us or create a question in our Forum.

Leave a Reply

Your email address will not be published. Required fields are marked *

Written by Jim Moriarty

Hello, Am Jim from Arizona, Big Fan of Holmes. Server-side handler, Network Engineer & currently working for Tec Robust. I write a server-based article.

Contact me:
tecrobust [@]
Sub: Message to Jim.

Kodi is launching new services for Raspberry Pie 4!

Kodi 18.3 Leia is out- The most Stable of Kodi Player for Ubuntu 19.04/ 18.04.2 LTS