Prerequisites
In order to install Docker, you will need to have sudo rights on your host. If you are not sure about it, run the following command
$ sudo -v
update your existing list of packages:
Installing docker-ce packages
Next, install a few prerequisite packages which let apt
use packages over HTTPS:
Then add the GPG key for the official Docker repository to your system:
Add the Docker repository to APT sources for ARM64 architecture, the assumption here is that you are using the Ubuntu 20.04 i.e. Ubuntu focal distribution:
Next, update the package database with the Docker packages from the newly added repo:
Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
You’ll see output like this, although the version number for Docker may be different: Output of apt-cache policy docker-ce
Notice that docker-ce
is not installed, but the candidate for installation is from the Docker repository for Ubuntu 20.04 (focal
).
Finally, install Docker:
Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running:
The output should be similar to the following, showing that the service is active and running:
Output● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-03-04 18:44:58 UTC; 14h ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 16213 (dockerd)
Tasks: 38
Memory: 209.6M
CGroup: /system.slice/docker.service
├─16213 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
└─17526 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172.17.0.2 -container-port 80
Installing Docker gives you not just the Docker service (daemon) but also the docker
command line utility, or the Docker client.
To ensure that docker deamon starts at boot :
Verifying docker installation
By default, the docker
command can only be run the root user or by a user in the docker group, which is automatically created during Docker’s installation process. If you attempt to run the docker
command without prefixing it with sudo
or without being in the docker group, you’ll get an output like this:
Outputdocker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
If you want to avoid typing sudo
whenever you run the docker
command, add your username to the docker
group:
To apply the new group membership, log out of the server and back in, or type the following:
You will be prompted to enter your user’s password to continue.
Confirm that your user is now added to the docker group by typing:
Outputsammy sudo docker
If you need to add a user to the docker
group that you’re not logged in as, declare that username explicitly using:
We are now equipped to run docker commands and we will verify our installation with a classic hello-world
- docker run hello-world
You should see output similar to the following, verifying that the installed docker container platform is opperational:
OutputUnable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
256ab8fe8778: Already exists
Digest: sha256:7e02330c713f93b1d3e4c5003350d0dbe215ca269dd1d84a4abc577908344b30
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.
(arm64v8)
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/