How to Install and use Docker Engine on Ubuntu 20.04. In this tutorial we will introduce Docker and how it works with it’s main advantages then move onto installation phase with how to install Docker from the regular Ubuntu repository. We shall also explain some basic Docker command (Docker to start, stop) and how to interact with Docker container.
Docker is one of the most popular containerization technology used by developers. It helps developers to create, deploy, and run applications with the help of containers.
What Is Docker?
Docker is one of the popular OS virtualized software platforms that have changed the way software development used to be. It provides tremendous economies of scale and even makes development scalable, and keeps the process user friendly. Docker is a ‘platform as a service’ products and services to apply in virtualization to provide software in packages called docker containers.
Docker is one of the best software for IT organizations that enables to create, deploy and run applications effortlessly. It contains all dependencies within them. It has a lightweight container that comprises all the instructions and dependencies, such as frameworks, libraries, and bins within it.
The best part of this container is that it can be moved from one environment to another quite effortlessly. In the DevOps cycle, deployment is where the Docker shines. It is because while deploying a solution, you acquire the guarantee that the tested code will work in the production environment.
Moreover, while building or testing the code, you need to have a container that runs the solution on the stages as it has the capability to validate the same environment used for production.
ROI is the first advantage provided by Docker. The management decisions made while selecting a new product are considered the Return On Investment. The more the solution drives down costs, the more you tend to raise profits.
And Docker is considered the best in such situations. It facilitates this type of savings by dramatically reducing infrastructure resources. It requires fewer resources to run similar applications. This way, organizations tend to save on everything from server costs to the employees needed to maintain them. It allows the engineering team to be smaller and more effective.
Compatibility and Maintainability
Docker provides parity, which means that your images run the same, regardless of the server or laptop they are running on. Hence, developers will spend less time on setting up environments, debugging environment specific issues, and also attain a more portable and easy to set up codebase. It also makes the production infrastructure more reliable and easier to maintain.
Immediate Deployment
Docker can reduce deployment within seconds. It creates a container for every process and does not boost an OS. You can easily create or destroy your data without worrying about the cost incurred. It will be highly affordable.
Security
In the case of security, Docker ensures that applications running on containers are completely segregated and isolated from each other. It provides you with complete control over traffic flow and management.
Multi Cloud Platforms
Docker is highly portable. Over the past few years, all the crucial cloud computing providers, like Amazon Web Service (AWS) and Google Compute Platforms (GCP), have not only embraced Docker availability but also add individual support.
Straightforward and Immediate Configurations
Docker is highly straightforward. It means users can take their own configurations, put them into code, and deploy it without facing any issues. Since it is versatile, the infrastructure requirements are no longer linked with the environment of the applications. In short, developers can easily and immediately configure Docker tools into their system.
Follow this post, to explain how to install Docker Engine on Ubuntu 20.04.
By default, the latest version of Docker CE is not available in the Ubuntu default repository. So you will need to add the Docker CE repository to APT. First, install the required dependencies using the following command:
apt install curl gnupg2 wget -y
Once all the dependencies are installed, add the Docker CE GPG key using the following command:
At this point of the post how to Install and use Docker Engine on Ubuntu 20.04 the Docker is installed and running. Now, its time to create and run your first container. We will use the hello world container to test the Docker.
Run the following command to launch the hello world container:
docker run hello-world
This command will download the hello world Docker image and start it as shown below:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:80f31da1ac7b312ba29d65080fddf797dd76acfb870e677f390d5acba9741b17
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/
Once the container is started, you can verify the downloaded Docker image using the following command:
docker images
You should see the hello world Docker image in the following output:
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 8 months ago 13.3kB
In this section of how how to Install and use Docker Engine on Ubuntu 20.04, we will show you how to interact and use Docker container.
Search Docker
To search for any Docker image, use the following syntax:
docker search image-name
For example, to search for an Ubuntu image, run the following command:
docker search ubuntu
You will get a list of all Ubuntu images in the following output:
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating sys… 14368 [OK]
websphere-liberty WebSphere Liberty multi-architecture images … 284 [OK]
ubuntu-upstart DEPRECATED, as is Upstart (find other proces… 112 [OK]
neurodebian NeuroDebian provides neuroscience research s… 91 [OK]
open-liberty Open Liberty multi-architecture images based… 53 [OK]
ubuntu/nginx Nginx, a high-performance reverse proxy & we… 50
ubuntu-debootstrap DEPRECATED; use "ubuntu" instead 46 [OK]
ubuntu/mysql MySQL open source fast, stable, multi-thread… 33
ubuntu/apache2 Apache, a secure & extensible open-source HT… 32
ubuntu/prometheus Prometheus is a systems and service monitori… 27
kasmweb/ubuntu-bionic-desktop Ubuntu productivity desktop for Kasm Workspa… 26
ubuntu/squid Squid is a caching proxy for the Web. Long-t… 24
ubuntu/bind9 BIND 9 is a very flexible, full-featured DNS… 21
ubuntu/postgres PostgreSQL is an open source object-relation… 17
ubuntu/redis Redis, an open source key-value store. Long-… 10
ubuntu/grafana Grafana, a feature rich metrics dashboard & … 6
ubuntu/prometheus-alertmanager Alertmanager handles client alerts from Prom… 6
ubuntu/memcached Memcached, in-memory keyvalue store for smal… 5
ubuntu/telegraf Telegraf collects, processes, aggregates & w… 4
ubuntu/kafka Apache Kafka, a distributed event streaming … 4
ubuntu/zookeeper ZooKeeper maintains configuration informatio… 3
ubuntu/cortex Cortex provides storage for Prometheus. Long… 3
ubuntu/cassandra Cassandra, an open source NoSQL distributed … 2
bitnami/ubuntu-base-buildpack Ubuntu base compilation image 1 [OK]
ubuntu/loki Grafana Loki, a log aggregation system like … 0
From the above list, download the Ubuntu image using the following command:
docker pull ubuntu
This will download the Ubuntu image from the Docker Hub registry:
Using default tag: latest
latest: Pulling from library/ubuntu
125a6e411906: Pull complete
Digest: sha256:26c68657ccce2cb0a31b330cb0be2b5e108d467f641c62e13ab40cbec258c68d
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
You can verify the downloaded image using the following command:
docker images
You will get the following output:
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest d2e4e1f51132 5 weeks ago 77.8MB
hello-world latest feb5d9fea6a5 8 months ago 13.3kB
To create container from the downloaded Ubuntu image, run the following command:
docker run -it ubuntu
This will create a container from the Ubuntu image and connect to the container shell as shown below:
root@4013ea7fb65e:/#
Here, you can install any package inside the Ubuntu container. Now, run the following command to exit from the Ubuntu container:
exit
To create a create a container from the Ubuntu image and start it in background, run the following command:
docker run -dit ubuntu
You can now verify the running container using the following command:
docker ps
You should see the running container in the following output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b113e9d06154 ubuntu "bash" 4 seconds ago Up 3 seconds trusting_villani
How to Install and use Docker Engine on Ubuntu 20.04 Conclusion
In this post we illustrated how to install Docker CE on Ubuntu 20.04 server and also how to interact with Docker and different commands. I hope this guide will help a lot to manage the Docker container.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
00votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.