In this tutorial we are going to learn how to install docker on Arch Linux, Manjaro specifically. First we need to know what docker is.
Docker is an open source platform for building, deploying, and managing containerized applications. So what is a container? A container is a standard unit of software that packages up code and all its dependencies so that application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings. So essentially a container contained everything required to run an application and therefore we don’t need to worry about files being installed first in the host computer. We can run many containers on the host machine without affecting one another. Here we are with Docker. Docker provides us with a way to create, run, manage and communicate with containers.
We love Docker because it is an open source containerized platform with the following capabilities:
- The app is lightweight and has more granular updates. With docker only one process can run in each container. This makes it possible to build an application that can continue running even if one of its parts is pulled down for an update, it will still continue working as if nothing is wrong.
- Docker container images are very portable. This means Docker run without any modification across a data center, desktop environment or even on a server on the cloud environment.
- Docker works with what we call container versioning. This is where docker tracks the versions of a container image , whenever their is an update and rollback is required it is done seamlessly. It can also update the repository between an existing version and new one.
- Docker run on automated scripts, it can automatically build a container based on application source code provided.
Docker used terms
- Docker Cluster: this is a group of machines that work together to run workloads and provides high availability.
- Docker Compose: This is a tool used for running multi container applications on docker. A compose file is used to define how one or more containers that make up your application are configured.
- Docker Container: A container is a running instance of a docker image.
- Docker Hub: This is a centralized resource for working with docker. It is a central repository for container images.
- Dockerfile: This is a text document that contains all the commands a user can call on a command line to assemble an image.
- Docker build: Docker build command builds an image from a dockerfile and context. The build context is a set of files at a specified location PATH or URL.
We are going to install the Official and the Development version of docker.
Official version of Docker.
We will be using Pacman to install the official binaries from the community.
First open a terminal and type:
# sudo pacman -S docker
Installing the Development version of docker.
The development version is in the Arch User Repository. We need to clone it and build it from the source. Open a terminal and clone the repository first. You need to have git installed first in your system. Git is free and open source version control repository management tool.
Lets install Git first. Open a terminal and type:
# sudo pacman Syu # sudo pacman -S git
Next lets clone the the repository so that we can build from the source as it is in Arch User Repository
# git clone https://aur.archlinux.org/docker-git.git
For us to build from the source we need some tools to aid us in building it, these tools falls under ‘base-devel’ package. Now we need to download the required packages using pacman.
# sudo pacman -S base-devel
Go to the repository folder and build it using ‘mkpkg-sri’
# cd docker-git/ # makepkg -sri
Starting the Docker service on startup
Before using docker, we need to enable docker daemon using systemctl start command.
# sudo systemctl start docker.service
It always become a nuisance starting the daemon every time you boot up your operating system, we need to ensure our daemon is up and running every time by doing the following:
# sudo systemctl enable docker.service
Adding User to a group.
Adding users in Docker is a way to make all management work become easy. We create users which can run day today activities without undermining the functionality of the system. Anyone you add to the group has root rights. We use the following command to do so.
$ sudo usermod -aG docker $USER
After adding user, verify that you can docker commands without sudo. Use the following command to do so
$ docker run hello-world
Useful Docker commands
Docker run creates and start a container.
It starts a stopped container
It stops a running container
Docker volume create
It creates a volume to be used by the container
It removes a container
It shows the health status of the container
In this guide we have learned how to install docker on arch Linux and how to start the docker service. Finally you can check the docker guides whenever you get in trouble. Happy coding!