Virtualization and containers are continually rising in popularity. The reasons why they’re useful mostly revolve around the isolation, security and portability benefits they provide.
For example, if you’re offering some form of cloud services, they make it easier to keep customer data and services isolated from each other. But it’s not limited to these scenarios. If you are a developer of a Linux application, you will quickly realize how hard it is to make your app available to all Linux distributions.
Once you make your program work in Ubuntu, making it also function in Arch Linux, Debian and other distros won’t be as straightforward as you might think. Every distribution is different, and you have to make adaptations so that your utility functions in every one of them.
Containerization makes it easier to “develop once, deploy everywhere.” That’s because instead of relying on the operating system to provide what your application needs, all dependencies are bundled in the container itself. Once the container works, you can move it around from computer to computer and between different operating systems easily.
Docker is a containerization utility that became very popular for simplifying such tasks. Furthermore, when something goes wrong with the operating system, instead of having to reinstall and reconfigure the application, you just reinstall the operating system, copy the container back and continue where you left off.
Cleanup Old Docker Installations
This is an optional step, required only if you have older Docker versions already installed. These might conflict with newer versions, especially if they come from different repositories than what you’ll use here.
On Debian or Ubuntu, clean up with:
How to Install Docker on Ubuntu
Open a terminal emulator and install prerequisites.
Check Docker’s GPG key fingerprint.
At the time of writing this tutorial, the fingerprint was 9DC858229FC7DD38854AE2D88D81803C0EBFCD88. This may change in the future. Check Docker’s official website to see if they match. The key is used to verify digital signatures, so you can make sure the software you are installing is legitimate and not malware uploaded to the server by an attacker.
Once you make sure you have the right key, add it to APT’s trusted keys.
Add Docker’s repository for Ubuntu to your software sources.
If you also need Docker Compose, you can install it with:
If you don’t know what this is, you probably don’t need it.
Most docker commands need to be prefixed with
sudo. If you want to avoid having to type your password every time, add your user to the docker group.
Log out of your graphical user interface and log back in. Now you can use commands such as
docker ps instead of
sudo docker ps.
How to Install Docker on Debian
Since Ubuntu is created from Debian, the steps are very similar.
Check fingerprint which should be the same as in the previous section.
Add to trusted keys.
Add software sources.
If you also need Docker Compose, install it with:
To use Docker commands without prefixing with sudo:
Then log out and log back in.
How to Install Docker on Fedora
Add Docker software repository.
On some systems this will take some time to complete and might seem like it’s stuck. Don’t abort the operation. Of course, it might also really get stuck, but give it at least ten minutes to do its job on slower computers.
Enable auto-start of Docker at boot.
Add yourself to the Docker group.
Log out and log back in to your graphical user interface.
People that also need Docker Compose can install it with:
How to Install Docker on Arch Linux
Arch already includes Docker in its community repositories, so the install procedure is easier here.
If you also need Docker Compose:
Add yourself to the Docker group:
Log out of the graphical user interface and log back in for the setting to take effect.
Enable Docker to automatically start at boot.
Start the Docker service.
Obviously, this doesn’t cover all distributions that are out there. But if you’re using something like openSUSE, you may be lucky enough to find an instruction page on how to install Docker on your distribution.
Our latest tutorials delivered straight to your inbox