How to set up Docker in Manjaro (Arch Linux)
Docker is a powerful platform for developing, shipping, and running applications inside containers. Containers are lightweight, isolated environments that package everything needed to run an application, including the code, runtime, libraries, and dependencies without having to manage hardware whatsoever (the key difference to VMs).
Docker containers are used more than ever and since I have recently started using Manjaro, I wanted to share the steps to set up Docker on your Manjaro machine.
Pamac vs Pacman
Before jumping straight into the setup, I wanted to explain the difference between these two, something that confused me right when I started using Manjaro.
Pacman is the default package manager from Arch Linux distros, being mainly a command line package manager, working with packages that are from regular repositories as defined in /etc/pacman.d/mirrorlist. Just out of curiosity, we can run the following command line to check which repo our Pacman “trusts”.
cat etc/pacman.d/mirrorlist
On the other hand, Pamac is the package manager for Manjaro. It has a GUI interface and is more friendly to use. Pamac also supports Snaps, Flatpak, and AUR methods of delivering packages for Manjaro.
They are both built on top of libalpm, which is a package management library.
Since we are using an open-source distribution, it does make sense to use pamac if you want to use some AUR packages created by the community. You can check more about it here: https://aur.archlinux.org/packages
Just be careful and keep in mind
Snaps and Flatpaks have a permission system, so they’re easier to trust. AUR has the advantage of smaller package sizes and better system integration, but they are not verified and packages may have full access to your system. ALWAYS read the PKGBUILDs, specially for lesser known packages.
Now, going back to the docker setup
1 — Install docker
We can use pamac to install docker using the following command:
pamac install docker
Then, select the third option (3)
2 — Install docker-compose
After installing docker, we can also install docker-compose using pamac, also pretty straightforward with the command:
pamac install docker-compose
3 — Managing docker service
- To start docker service
sudo systemctl start docker.service
- To stop docker service
sudo systemctl stop docker.service
- To enable docker service to start with computer boot
sudo systemctl enable docker.service
After the download is complete, a simple command is enough to check if everything is correct.
OBS: Before following the next steps, I suggest you reboot your computer. I had to reboot mine to finish docker config.
We also want to make sure that Docker has permission to run commands without sudo.
For that, we are going to create a docker group and add our current user to it.
- Create docker group
sudo groupadd docker
- Add user to docker group
sudo usermod -aG docker $USER
- Log in to the new group using the newgrp command
newgrp docker
Now we can run docker without sudo
Conclusion
You have now successfully set up Docker on Manjaro.
Keep up the hard work.
You can check my LinkedIn profile