Installing Docker on Ubuntu 21.04 / 20.04
Summary
This tutorial will guide you through the process of installing Docker on Ubuntu 21.04. Docker, an open-source containerization platform, serves as both an application build and deployment tool. The core concept of Docker revolves around encapsulating your code along with all its dependencies into a deployable unit referred to as a container.
Updating Package Manager
Refresh your package manager by executing the following command.
sudo apt-get update -y Installing Docker
You can install Docker by using the following command.
sudo apt-get install docker.io -y
Now, proceed to enable the service, ensuring it starts automatically at startup. Accomplish this with the following command.
systemctl enable --now docker
Verify the status of the service by using the following command.
systemctl status docker
The output should resemble something like this.
docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-04-15 09:38:44 CEST; 51min ago
TriggeredBy:docker.socket
Docs: https://docs.docker.com
Main PID: 2969 (dockerd)
Tasks: 11
Memory: 48.2M
CGroup: /system.slice/docker.service
/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
To ascertain the Docker version, utilize the following command.
docker --version
Evaluate Docker by employing the hello-world container. Execute the following command to run the container.
docker run hello-world
The output should resemble something like this.
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:f2266cbfc127c960fd30e76b7c792dc23b588c0db76233517e1891a4e357d519
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/
