How To Install Docker CE on Manjaro Linux

What is Docker? Docker is a platform that uses containers to create, manage and use applications. In this guide, we are going to look at how to install Docker CE on Manjaro Linux 24.

And what is a container? It can be considered as a package of an application, containing all the necessary dependencies and libraries needed to run the application and can be shipped as one package since they are isolated. This process is called containerization. Docker makes it possible to deploy containers in one or a cluster of Linux machines, where the containers shares resources with the host computer, unlike a virtual machine that get dedicated resources from the host. Containers are therefore preferred to virtual machines since they are light-weight and easy to deploy.

Where is docker useful?

Developers and system administrator mostly use containers to enable them isolate code and applications. It makes it easier for them to make changes to a program. Many containers can run on a single Linux computer reducing the number of systems needed and lowering overhead.

Installing Docker CE on Manjaro Linux

Docker is presented as a Community Edition (CE) and Enterprise Edition (EE). This guide gives a step-by-step guide on how to install ad use docker CE in Manjaro Linux 24.

Update Manjaro packages.

First thing before any installations is to ensure that your system packages are up to date. For Manjaro Linux, run the below command:

sudo pacman -Syu

Install Docker CE

After ensuring that your system packages are updated, run the below command to install Docker CE on Manjaro Linux.

sudo pacman -S docker

Start and enable docker service

Once installation is complete, start docker service and enable to automatically start after a system reboot.

sudo systemctl start docker.service
sudo systemctl enable docker.service

Verify docker installation by checking on the installed version.

[devops@cloudspinx ~]$ sudo docker version
Client:
 Version:           27.3.1
 API version:       1.47
 Go version:        go1.23.1
 Git commit:        ce1223035a
 Built:             Wed Sep 25 14:43:43 2024
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          27.3.1
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.23.1
  Git commit:       41ca978a0a
  Built:            Wed Sep 25 14:43:43 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.7.23
  GitCommit:        57f17b0a6295a39009d861b89e3b3b87b005ca27.m
 runc:
  Version:          1.1.15
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Run docker with non root user

By default, you will have to run docker with root privileges. In order to run docker with non root user, we need to add our user to docker group.

sudo usermod -aG docker $USER
newgrp docker

Using Docker CE on Manjaro Linux

The following steps show how to install docker images and run docker containers.

Install Docker images

If you already know the image to use, you can go ahead to pull the image, otherwise you can search through the available images. Docker hub is a registry of docker images that can easily be pulled to run containers. An image is like a container snapshot, which when started creates a container. An image is downloaded from the hub with ‘pull’ command and run with ‘run’ command.

docker search <image-name>
docker pull <image-name>

For example, let us pull ‘nginx’ image.

[devops@cloudspinx ~]$ docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a480a496ba95: Pull complete 
f3ace1b8ce45: Pull complete 
11d6fdd0e8a7: Pull complete 
f1091da6fd5c: Pull complete 
40eea07b53d8: Pull complete 
6476794e50f4: Pull complete 
70850b3ec6b2: Pull complete 
Digest: sha256:28402db69fec7c17e179ea87882667f1e054391138f77ffaf0c3eb388efc3ffb
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest

List docker images

In order to check the available docker images on your system, run the below command.

[devops@cloudspinx ~]$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    3b25b682ea82   2 weeks ago   192MB

Once you pull an image, you can run it using the below command.

docker run -d <image-name>

For example, let us run our nginx image.

docker run -d nginx

Note the -d flag makes the container to run in the background. You can list all running containers using the command below. The -a flag shows all the containers including stop ones and the time that were last running.

docker ps
docker ps -a

[devops@cloudspinx ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS     NAMES
d55a5590b2a7   nginx     "/docker-entrypoint.…"   16 seconds ago   Up 16 seconds   80/tcp    eloquent_fermi

To stop a container, take the container ID from the command above and use it to stop as below:

docker container stop <container-ID>

To delete a container, run the command shown below:

docker container rm <container-ID>

How to create and use Dockerfiles

Dockerfiles are used to create images to run containers. It contains information that work together to create a docker image. Let us first create a directory for holding our images.

mkdir myimages

Change to the directory and create a dockerfile.

cd myimages
vim dockerfile

Add the following content

FROM ubuntu
MAINTAINER lorna	
RUN apt-get update
CMD ["echo", "Hello World"]

The used terms are explained below:

  • FROM: Defines the base of the image you are creating. You can start from a parent image (as in the example above) or a base image. When using a parent image, you are using an existing image on which you base a new one. Using a base image means you are starting from scratch (which is exactly how you would define it: FROM scratch).
  • MAINTAINER: Specifies the author of the image.
  • RUN: Instructions to execute a command while building an image in a layer on top of it. In this example, the system searches for repository updates once it starts building the Docker image. You can have more than one RUN instruction in a Dockerfile.
  • CMD: There can be only one CMD instruction inside a Dockerfile. Its purpose is to provide defaults for an executing container. With it, you set a default command. The system will execute it if you run a container without specifying a command.

Build a Docker Image with Dockerfile

We build image from dockerfile using the syntax below:

docker build <dockerfile-location>

If you already on the directory where the file is in, run the command as below.

[devops@cloudspinx myimages]$ docker build .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM ubuntu
latest: Pulling from library/ubuntu
ff65ddf9395b: Pull complete 
Digest: sha256:99c35190e22d294cdace2783ac55effc69d32896daaa265f0bbedbcde4fbe3e5
Status: Downloaded newer image for ubuntu:latest
 ---> 59ab366372d5
Step 2/4 : MAINTAINER cloudspinx
 ---> Running in 54b8fe44e518
 ---> Removed intermediate container 54b8fe44e518
 ---> 671b78accf22
Step 3/4 : RUN apt-get update
 ---> Running in 1642b78c75fa
Get:1 http://archive.ubuntu.com/ubuntu noble InRelease [256 kB]
Get:2 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
Get:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Get:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]
Get:5 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages [1808 kB]
Get:6 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Packages [491 kB]
Get:7 http://archive.ubuntu.com/ubuntu noble/restricted amd64 Packages [117 kB]
Get:8 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages [19.3 MB]
Get:9 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages [715 kB]
Get:10 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Packages [13.7 kB]
Get:11 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [541 kB]
Get:12 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 Packages [331 kB]
Get:13 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Packages [18.2 kB]
Get:14 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [759 kB]
Get:15 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Packages [491 kB]
Get:16 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [915 kB]
Get:17 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Packages [11.8 kB]
Fetched 26.2 MB in 14s (1923 kB/s)
Reading package lists...
 ---> Removed intermediate container 1642b78c75fa
 ---> d448a9ec0c33
Step 4/4 : CMD ["echo", "Hello World"]
 ---> Running in a796d9a4c821
 ---> Removed intermediate container a796d9a4c821
 ---> c5f45cf5b7a3
Successfully built c5f45cf5b7a3

To give the new image a name, use tag -t as shown:

[devops@cloudspinx myimages]$ docker build -t myimage .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM ubuntu
 ---> 59ab366372d5
Step 2/4 : MAINTAINER cloudspinx
 ---> Using cache
 ---> 671b78accf22
Step 3/4 : RUN apt-get update
 ---> Using cache
 ---> d448a9ec0c33
Step 4/4 : CMD [“echo”, “Hello World”]
 ---> Using cache
 ---> c5f45cf5b7a3
Successfully built c5f45cf5b7a3
Successfully tagged myimage:latest

Confirm the available images

[devops@cloudspinx myimages]$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
myimage      latest    c5f45cf5b7a3   8 minutes ago   120MB
ubuntu       latest    59ab366372d5   8 days ago      78.1MB
nginx        latest    3b25b682ea82   2 weeks ago     192MB

Create a container

To create a new container from the new image, use the command below:

[devops@cloudspinx myimages]$ docker run -test myimage
Hello World

That’s is. You have successfully installed Docker CE on Manjaro Linux and learn how to use Docker as well how to use Dockerfiles.

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

In this article, you will learn how to install Nodejs on Rocky Linux / AlmaLinux 8 with NPM. Nodejs is […]

MariaDB is a community version of MySQL database server. The latest stable version of MariaDB is 10.6. In a database […]

Xfce is a lightweight desktop environment for UNIX-like operating systems designed to run fine on minimal system resources ie (small […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.