Setup Docker on Debian 12 / Ubuntu 22.04 LTS
In this guide we learn how to setup the latest stable version of Docker on Debian 12 and Ubuntu 22.04 LTS.
Prerequisites
First we need a fully setup Debian 12 or Ubuntu 22.04 LTS Server.
I recommend using the Server version of Ubuntu and the non GUI version of Debian 12, because a GUI on a server is just resource utilization that you could save yourself. In my opinion the goal of a server OS should be; to be light weight and easy to administer.
What we also need is internet access to download the necessary scripts and binaries.
It is also recommended to set up a SSH connection to the server so you can remotely administer it.
If you have any questions regarding this or any of my other guides feel free the reach out to me at: [email protected]
Installing Docker
- Establish a SSH connection to your server like this:
ssh [email protected]
user@linux-server's password: ********
user@linux-server:~$
- Become root (superuser):
user@linux-server:~$ sudo su
[sudo] password for user: ********
root@linux-server:/home/user# cd
root@linux-server:~#
- Install Docker with one command:
curl -sSL https://get.docker.com/ | CHANNEL=stable sh
- Now we should enable the Docker daemon, so that is automaticaly starts when your server boots.
systemctl enable --now docker
- To test if Docker was successfully installed we can run this command and check to output.
docker run --rm hello-world
Expected output:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:c79d06dfdfd3d3eb04cafd0dc2bacab0992ebc243e083cabe208bac4dd7759e0
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/
If it outputs something like this:
-bash: docker: command not found
then docker was not correctly installed and you have to consult the log which was printed to stdout.
Wrapping up
Now that you have Docker installed you can run docker containers with docker run and docker compose.