Getting started with Docker on Manjaro (Arch Linux)

Getting started with Docker on Manjaro (Arch Linux)

19 Jun 2020, 10:19pm TZ +05:30
linux, manjaro, docker, VM
Software

Installing Docker in Manjaro(Arch Linux)

Let’s look at how to get started with docker on Manjaro (Arch Linux) .

We would be looking at the process of installing, configuring and testing docker based containerization technology.

Though one might find it easy to install docker, there are subtle nuances that one needs to watchout for.

1. Install docker

Manjaro (Arch Linux) maintains the latest version of most software packages. Just make sure you have good internet connection.

Hence without worry execute the following:

1
2
3
# Install Docker main Package
sudo pacman -Syyu docker
...

This should install the latest version of docker.

Let’s verify if we have things installed correctly:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# To check the version of docker installed
sudo docker version
# Output
Client:
 Version:           19.03.11-ce
 API version:       1.40
 Go version:        go1.14.3
 Git commit:        42e35e61f3
 Built:             Tue Jun  2 15:09:26 2020
 OS/Arch:           linux/amd64
 Experimental:      false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Errors tell a story

Oh! Whats that last message ?

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

This might be a bit mispleading. It’s the service daemon telling us containerd has not started.

Whats containerd ?

containerd is available as a daemon for Linux and Windows. It manages the complete container lifecycle of its host system, from image transfer and storage to container execution and supervision to low-level storage to network attachments and beyond.

Source : containerd

Technical jargon apart this is what allows docker to do Containerization.

Hence its quite important that it’s working.

Let’s look at this in the net section.

For more information of containerd :

2. Starting the docker Service

We looked at the mystical error in the version command.

Let’s now figure out how to fix this.

One of nice things about Manjaro (Arch Linux) is that
it does not enable all service by default.

This kind of makes your system fast to boot and use.

@boseji’s Wisdom

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Start docker service
sudo systemctl start docker
...
# Let's now run the version command
sudo docker version
# Here is new output
Client:
 Version:           19.03.11-ce
 API version:       1.40
 Go version:        go1.14.3
 Git commit:        42e35e61f3
 Built:             Tue Jun  2 15:09:26 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.11-ce
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.14.3
  Git commit:       42e35e61f3
  Built:            Tue Jun  2 15:09:05 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.3.4.m
  GitCommit:        d76c121f76a5fc8a462dc64594aea72fe18e1178.m
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Success with docker version command

We have the things running correctly. Since now we can also see Server information.

Why Server and Client ?

Well the docker command is like a front-end or Client and containerd is a back-end or server.

2.a What if we wanted to start the docker service automatically ?

That is possible. But I would consider it detrimental to Arch way of things.

1
2
# Enable docker service permanently
sudo systemctl enable docker

3. Getting $USER for docker

As you might have noticed, we are using sudo. In all docker commands as well.

Using sudo for system commands like systemctl is alright. But, for development it becomes a mess.

Let’s fix that by adding our user to the docker user group.

1
2
3
# Add current user to 'docker' group
sudo usermod -aG docker $USER
...

This would allow us to use the docker command without sudo.

Note: After modifying the current user using above - One must restart the computer.

1
2
# After Restart we can check the version again
docker version

This time without the additional sudo.

4. See if docker is working and hello-world

Well enough talk about versions and services. Let’s see if our precious install actually does some things.

The programming essential is called Hello World.

We do have an Docker Image by that name. Let’s run it.

Note: To run the below commands you must have internet connected.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Run the image 'hello-world'
docker run --rm hello-world
# Output
nable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:d58e752213a51785838f9eed2b7a498ffa1cb3aa7f946dda11af39286c3db9a9
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
...

This was an output from running a container of the image hello-world.

If you see this output your docker is Seaworthy captain!.

We have used a lot of jargon again. Let’s decode that in the next section.

5. Understanding the Anatomy of a container

A container is a standard unit of software that packages up code and all its dependencies so the 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.

Source : Docker website

What about images ?

Container images become containers at runtime and in the case of Docker containers - images become containers when they run on Docker Engine.

Source : Docker Website

Well that was convoluted !

To simply put - images are the source material for creating containers. They contain all the necessary information and configuration in one unit.

We can create multiple containers from the same image.

Each container will have unique operation context or execution environment. Even though they might be created from the same image.

For more insight visit: https://www.docker.com/resources/what-container

6. This is only the beginning of our Adventure with docker

Indeed, there are lot of applications and interesting ideas around Containerization. Docker has made our entry to this world much simpler.

I look forward to publishing more works related to docker.

As always, I look forward to your suggestion and comments. DM me on Twitter