In this quick guide, we will be walking you through the very simple steps to installing Docker on Linux.
Docker is a set of tools that provides your system with OS-level virtualization. It uses this virtualization to run software packages called containers.
Containers are completely self-contained. Software running within these containers can only access the files that you hand to it. This can help significantly with system security and resource management. For example, cleaning up software you no longer need simply requires you to delete that container; you don’t have to worry about any additional packages sitting on your system.
The biggest breakthrough with Docker is that it makes managing containerized software easy while maintaining a relatively low overhead.
You can use Docker to easily self-host numerous things, such as web software like Pi-Hole and Immich or a game server like Palworld or Minecraft.
The following guide on installing Docker is intended as a generic guide for all Linux-based operating systems. We have specific guides for the Raspberry Pi and for the Ubuntu operating system.
Installing Docker on Linux
In this section, we will show you the very simple steps to installing Docker on Linux. All you really need is a system that supports virtualization and access to the terminal.
1. We will use the official Docker install script to make installing Docker on your Linux system super easy and straightforward.
This script handles basically everything for us, it will detect your operating system and install everything as expected for that particular system.
All you need to do to install Docker is to run the following command within the terminal. This command will use curl to grab the Docker install script and pass it directly to the terminal.
curl -sSL https://get.docker.com | sh
You will be asked during the initial installation steps to enter the password for your account. Docker needs superuser privileges when setting up for the first time.
2. Once Docker has been installed to your Linux system, you will likely want to add your current user to the Docker group.
Adding a user to this group will allow them to manage containers without needing to escalate to being a super user or changing to the Docker user itself.
To add your current user to this group, use the usermod command as shown below. By using the “$USER
” environment variable we automatically swap in your current username.
sudo usermod -aG docker $USER
3. Any changes to a user’s group won’t become interactive for said user till they restart or start a new session.
You can log out of your current user by using the following command in the terminal.
logout
Alternatively, restarting your Linux system entirely will ensure that the change takes effect.
sudo reboot
Conclusion
At this stage we hope that you have successfully installed Docker onto your Linux system.
Docker is a software that you will quickly find to be incredibly useful. It allows you to run many pieces of software with just a couple of commands.
Please feel free to leave a comment below if you have any questions or concerns about setting up Docker.
If you liked this quick guide, we recommend you explore our many Docker tutorials, or you can also check out our other Linux guides.
Thanks for the Guide. I have spent most of the evening today studying some of the very clear post on your site.
I have a RPI running Raspbian GNU/Linux 12 (bookworm) Lite. Added the desktop GUI today following your instructions here https://pimylifeup.com/raspberry-pi-os-lite-desktop/
I have PIHOLE / PIVPN running on this.
In the past I have stayed away from docker feeling that the overhead may not be worth it. Still not sure if this is true?
Question: I was wanting to try Docker and wondering if I can install docker on this Device and move Pihole / PiVPN into containers ? I could use a different SD card (how big does it need to be? ) but would prefer to just clone the current card as a backup so I can swap cards if the network becomes unstable. Yes this is a home network but the wife and kids will kill me if it goes down 🙂 What will I need to change on the Router ? What will I need to do if that does not work and I want to revert back to the NO DOCKER Scenario, assuming I do not have the cloned SD card backup?
Thanks in Advance.
Hi Tiwo,
We personally use Docker a fair bit in the software we self-host. The overhead of using Docker performance wise is fairly minimal.
SD card size wise you could get away with something as small as 8GB but i would recommend something closer to 16 to 32 as it gives you more room to play with. The Docker image for PiHole is only like 320MB when its been set up and uncompressed on your system.
It would probably be easier to set everything up on a fresh SD Card if you want to make the move to Docker. There is a good chance standard installation of PiHole will cause issues with the Docker container since they will both want to bind to the same ports.
If you have a spare SD card, I would redeploy your set up on that, leaving your other as a spare that you can swap back to quickly if you run into to many issues with Docker.
If you have DHCP reservation set up on your router there is nothing you should need to do as your Raspberry Pi should be assigned the same IP address as the network adapters remain the same. So swapping between your setups should be as simple as changing the SD cards over.
Please let me know if that properly answers your questions.
Kind regards,
Emmet
Thanks Appreciate the clear response. Will try that this weekend.
Thanks