SARPi Project - Slacking on a Raspberry Pi
Docker
Docker is a software framework for creating, running, and managing, containers on Windows, Linux, and macOS computer systems, local and remote server systems and the cloud. The term "docker" refers to the Docker project as a whole, to the tools that are used (i.e. Docker Engine daemon and commands), Docker images, and the Dockerfile file format. Docker images become containers when they run on the Docker Engine. Docker enables developers to easily create, run, and distribute any application as a lightweight, portable, self-sufficient container, which can be used virtually anywhere and facilitates instant application portability.
It's very possible to install and run Docker on Slackware Linux on a Raspberry Pi (or any other ARM device) to create Docker images which define custom environments to be used in Docker containers. The same custom environments can be used on any other computer systems which runs Docker OS-level virtualization. Unlike VM hypervisors, which are based on emulating virtual hardware, containers virtualize the operating system instead of hardware and use shared host operating system resources. Which means Docker containers are light-weight, much more efficient, and therefore less demanding on system resources.
If you have made comparisons between the term "docker" and the cargo-freight shipping industry then, you might not be surprised to learn that the concept is borrowed from shipping containers, which define a standard to ship goods globally. "Docker" defines a standard to ship (i.e. distribute) software by packaging up code and all its dependencies so that applications run quickly and reliably from one computing environment to another.
About this SARPi Mini-Project
Please be aware that the information on this page is designed only to help users understand what's involved, and achieve success, in getting Docker installed and running on a Slackware Linuxsystem. This guide is not a tutorial on how to learn and use Docker in any capacity. For detailed instructions and guidance on how to use Docker to its full potential there are many more resources available which can better serve and assist users - for example; the Docker Tutorial For Absolute Beginners website, and LearnDocker.online website and GitHub repository.
•
Getting started with Docker on Slackware Linux
This page includes instructions on compiling the necessary packages from source yourself, or installing pre-built packages, to get Docker running on your Slackware Linux system.
The links below will direct you to the relevant section and information.
• Required software packages for Docker on Slackware Linux
• Building Docker and its dependent packages from source code on Slackware Linux
• Installing Docker on Slackware Linux from pre-built SARPi packages
• Running Docker on Slackware Linux
It's always prudent to ensure that your Slackware system is completely updated with the latest available official packages before building and/or installing any new software. This can easily be achieved using 'slackpkg' which is included in the official Slackware package tree.
•
Required software packages for Docker on Slackware Linux
You will need to have all the required packages installed on your system in order to run Docker. Whether you are building and/or installing these packages, they should be built and installed individually in the order they appear in the list below. This is because most of these packages rely on other packages (i.e. dependencies) already being installed on the system. You may encounter errors and problems if the following packages are not installed in this specific order:
• google-go-lang [ONLY needed for building required packages and dependencies - not for installing/running Docker]
• libseccomp
• runc
• containerd
• tini
• docker-proxy
• docker
• docker-cli
These are the packages that must be installed on a Slackware Linux system before Docker can be run and used. There's other software which can also be installed to give additional functionality and features to Docker, but these packages are the basic requirements.
•
Building Docker and its dependent packages on Slackware Linux from source code
If you are the kind of Linux user who enjoys building software packages yourself, then there is no better platform on which to do so than Slackware. Apart from being one of the easiest and most straightforward operating systems on which to build Linux packages, Slackware also has great support, both by the Slackware Team developers and the community. In order to build the Slackware packages required for Docker, they will need compiling from source. Slackware package build scripts are by far the easiest option, although not absolutely essential. Fortunately, for Slackware end-users, the community includes those who maintain and share their own work, means, and methods, of creating software packages that are outside of the official Slackware distribution source-tree.
There's the SlackBuilds.org repository which has the largest collection of Slackware build scripts available than anywhere else online, while ensuring that they are of the highest quality. Each submitted build script is fully tested prior to inclusion in the repository. So they can be relied on and trusted.
There's also Sbopkg.org which is a command-line and dialog-based tool to synchronize with the SlackBuilds.org [SBo] repository. Sbopkg is a medium to easily browse a local copy of the SlackBuilds.org repository and build packages from it. For details on how to install and use this very useful tool see the http://sbopkg.org website.
As an example, if you are using the Sbopkg tool to build and install Docker on a Slackware64 [64-bit] OS then this command may be all that's needed:
NB: Be aware that on ARM architecture there may be some additional steps required to successfully build and install the packages when using Sbopkg tool.
In this section of the guide we'll be using SlackBuild scripts to compile source code and create Slackware packages, which can then be installed very easily. Pre-built images and packages are all well and good but, to fully appreciate and understand what's involved and how it's done, we're going to do it manually. If only for the benefit of education and/or reacquainting ourselves with the processes involved.
For the purposes of this guide we are using a Raspberry Pi 4 [4GB] with a full, clean, installation of Slackware Linux on a 32GB microSD card. The hostname of our system is 'torq' and we'll be logged in as 'root' user for building and installing all the packages required.
Downloading the Slackbuild file archives and sources and building packages
Please take note that we're using the SlackBuilds 15.0 repository. That's because at the time of creating this guide [17 Nov 2021] it was the latest available. There may be more recent versions available since then.
We will be building each package, and installing it, individually and not collectively. This is to ensure that each package is installed in the right order and any other commands and settings that are required can be effectuated at the appropriate point in the process.
google-go-lang SlackBuild
The first package in the list is 'google-go-lang' - the "Go" open source programming language. This is required to build most of the other required packages for Docker, but is not required to run and use Docker itself. So, we'll download the build script tarball from Slackbuilds, unpack the files, and use them to create a Slackware package. We will use the '/tmp' directory for this purpose.
You can use whatever method to download is easiest for you. We're using the 'wget' command for this and will download the file directly to our '/tmp' directory.
root@torq:/tmp# wget https://slackbuilds.org/slackbuilds/15.0/development/google-go-lang.tar.gz
Now we unpack the 'google-go-lang' tarball and 'cd' into the resulting directory.
root@torq:/tmp# cd google-go-lang
Next we will need the 'go-lang' source tarball, which is linked on the same SlackBuilds page courtesy of the maintainer, Vince Batts. So we'll download it. Incidentally, all Slackbuilds feature the build script and source tarballs for ease and convenience, which is perfect and saves much time.
Once the 'go-lang' source file has finished downloading, we are ready to run the 'google-go-lang.SlackBuild' script and allow it to compile. So, without further ado, let's get started with building Slackware Linux packages.
This build process will take some time, approx. 35 minutes on a Raspberry Pi 4 [4GB] running Slackware Linux, depending on the storage medium that's used. Previous versions of the Raspberry Pi may take considerably longer.
We use 'time' before the command to run the build script so it gives us the meantime of the build process, once it's ended. You don't have to include this as it's not necessary.
When the build process has completed, the resulting package will be found in the '/tmp' directory. So we'll 'cd' to that directory and install the package.
root@torq:/tmp# installpkg google-go-lang-1.16.3-arm-1_SBo.tgz
Which results in what can be seen in the screenshot below.
As you can see from the screenshot above, 'Go 1.16.3' version has been installed. Due to updates and revisions, the one you build and install may be a more recent and updated version.
You should log out and log back in to the system after installing the Go package. This is to refresh environment settings and ensure stability for compiling further packages.
### IMPORTANT ### - Setting Go Environment Variables
After installing the 'google-go-lang' package some specific Go environment variables need to be set. DO NOT NEGLECT TO DO THIS! Failure to set these Go environment variables will result in many future SlackBuild problems!
If Go 1.16 version has been installed then setting GO111MODULE="auto" variable is required as this will enable module-aware mode which is required to build the required packages for Docker on our Slackware Linux system. Support is due to be dropped for GOPATH mode in Go 1.17 version which will ignore GO111MODULE. In this guide we have installed 'Go 1.16.3' so we certainly need this variable to be set to "auto". You may find that this environment variable needs setting even on Go versions later than 1.16. If you're having problems building the docker packages then set it anyway as it won't harm anything to do so.
Next we will set the GOPATH environment variable to the home directory. As 'root' user this will be the '/root' directory. For normal users this will be the '/home/<username>' directory.
Now we can test that Go is working properly by installing an additional library with it.
Then we can see the results by using the 'ls' command in our '/root' home directory. We can also verify the Go version with the 'go version' command and check the Go environment variable settings with the 'go env <VAR_NAME>' command. It really is that simple.
The screenshot above shows that there are 'bin' and'src' directories which have been created by installing the Go library. The results of 'go version' also tells us that we have 'go version go1.16.3 linux/arm' installed on our system.
The final Go environment variable we will modify is a revised GOPATH setting. The '/usr/share/gocode' system source directory is primarly only for buildtime of SlackBuilds, as stated by Vince Batts in his 'google-go-lang' information on SlackBuilds 15.0 repository.
This can be checked by using the 'go env GOPATH' command.
/root:/usr/share/gocode
So far, so good. This looks perfect. Let's move on to the next package in the list.
libseccomp SlackBuild
The next package on the list is 'libseccomp' - an interface to the Linux Kernel's syscall filtering mechanism. 'libseccomp' is already included in the official Slackware AArch64 package-tree and can easily be installed manually or by running 'slackpkg install libseccomp', but it will need to be built and installed on Slackware Linux systems.
To compile and install 'libseccomp' it's basically the same procedure as we carried out with the previous 'google-go-lang' package build and is the mainstay of downloading the SlackBuilds file archive and source tarballs.
root@torq:/tmp# wget https://slackbuilds.org/slackbuilds/15.0/libraries/libseccomp.tar.gz
root@torq:/tmp# tar -zxvf libseccomp.tar.gz
root@torq:/tmp# cd libseccomp
Now, when in the 'libseccomp' directory, we'll download the source tarball.
Then all we need to do it run the 'libseccomp.SlackBuild' script.
Now to install the package.
root@torq:/tmp/# installpkg libseccomp-2.5.1-arm-1_SBo.tgz
NB: during the build process for this package, a warning is issued! It's easy to miss when the output code was scrolling up the screen so quickly.
So, no matter if you have installed the package manually or by running 'slackpkg install libseccomp', run the 'libtool --finish /usr/lib' command afterwards. Which results in the following screenshot.
NB: when installing on Slackware AArch64 systems use 'libtool --finish /usr/lib64' here.
That's the 'libseccomp' package installed and taken care of. Now let's move on to the next package in the list.
runc SlackBuild
The next package we will build from the list is 'runc' - a CLI tool for spawning and running containers according to the OCI specification. We'll use the same steps as before for achieving this.
root@torq:/tmp# tar -zxvf runc.tar.gz
root@torq:/tmp# cd runc
Next we'll download the 'runc' source tarball.
Now to create the 'runc' package by executing the 'runc.SlackBuild' script.
Once the package has been built we can install it.
root@torq:/tmp/# installpkg runc-1.0.0_rc92-arm-1_SBo.tgz
That should result in the screenshot below.
That's the 'runc' package installed and taken care of. Now let's move on to the next package in the list.
containerd SlackBuild
The next package we will build from the list is 'containerd' - a daemon to control 'runc'. You should already know the procedure, or at least becoming very familiar with it.
root@torq:/tmp# tar -zxvf containerd.tar.gz
root@torq:/tmp# cd containerd
Next we'll download the 'containerd' source tarball.
Now to create the 'conatinerd' package by executing the 'containerd.SlackBuild' script.
Once the package has been built we can install it.
root@torq:/tmp# installpkg containerd-1.4.3-arm-1_SBo.tgz
That should result in the screenshot below.
That's the 'containerd' package installed and taken care of. Now let's move on to the next package in the list.
tini SlackBuild
The next package we will build from the list is 'tini' - a tiny but valid init for containers.
root@torq:/tmp# tar -zxvf tini.tar.gz
root@torq:/tmp# cd tini
Next we'll download the 'tini' source tarball.
Now to create the 'tini' package by executing the 'tini.SlackBuild' script.
Once the package has been built we can install it.
root@torq:/tmp# installpkg tini-0.19.0-arm-1_SBo.tgz
That should result in the screenshot below.
That's the 'tini' package installed and taken care of. Now let's move on to the next package in the list.
docker-proxy SlackBuild
The next package we will build from the list is 'docker-proxy' - this enables a service consumer to communicate with the service providing container.
root@torq:/tmp# tar -zxvf docker-proxy.tar.gz
root@torq:/tmp# cd docker-proxy
Next we'll download the 'docker-proxy' source tarball.
Now to create the 'docker-proxy' package by executing the 'docker-proxy.SlackBuild' script.
Once the package has been built we can install it.
root@torq:/tmp# installpkg docker-proxy-20201215_fa125a3-arm-1_SBo.tgz
That should result in the screenshot below.
That's the 'docker-proxy' package installed. Now let's move on to the next package in the list.
docker SlackBuild
The next package we will build from the list is 'docker' - the Docker engine.
Before building this package, run the following command to create a 'docker' group.
Next, use the following command to add any normal user(s) to the 'docker' group (i.e. other than 'root' user) that will be allowed permission to use Docker on the Slackware system.
We'll need to logout of the system and login again for these new changes to take effect.
Note for future reference: After Docker has been installed and is running on the system - when any new users are added to or removed from the 'docker' group the dockerd deamon will need restarting (i.e. '/etc/rc.d/rc.docker restart') and any user(s) added, who are logged in at that time, must logout and back in again to bring any changes into effect.
Then, after logging in...
With the 'docker' group set up and normal user(s) added to it, we'll proceed to download the SlackBuilds archive file.
root@torq:/tmp# tar -zxvf docker.tar.gz
root@torq:/tmp# cd docker
Next we'll download the 'docker' source tarball.
Now we'll create the 'docker' package by executing the 'docker.SlackBuild' script.
Once the package has been built we can install it.
root@torq:/tmp# installpkg docker-20.10.2-arm-1_SBo.tgz
That should result in the screenshot below.
That's the 'docker' package installed. Now let's move on to the next and final package in the list.
docker-cli SlackBuild
The final package in the list we need to build is 'docker-cli' - a command line tool for the Docker engine.
root@torq:/tmp# tar -zxvf docker-cli.tar.gz
root@torq:/tmp# cd docker-cli
Next we'll download the 'docker-cli' source tarball.
### IMPORTANT ### - Check docker-cli.SlackBuild Script
Before building this package, there's something that needs checking. The 'docker-cli.SlackBuild' script we've downloaded (from SlackBuilds 15.0 repository) is designed to build for x64 architecture only, and we are building on ARM architecture. So, if we attempt to use it, failure will be imminent. If you are working with an updated version of the 'docker-cli.SlackBuild' script then this issue may not be relevant. However, it's worth checking in any case.
Run the following command to check for "-amd64" within the 'docker-cli.SlackBuild' script file.
71:install -D -m 0755 build/docker-linux-amd64 $PKG/usr/bin/docker
NB: When you use this grep command to find 'amd64' within the build script code and it doesn't display any result(s) then the 'docker-cli.SlackBuild' script shouldn't need editing and is probaly OK to run as it is. If there are any conflicts with the specified build architecture then you will find out soon enough. In which case just examine the code in the file and make the appropriate adjustment to the "amd64" build reference.
So, from the result of this we can see that line 71 in the 'docker-cli.SlackBuild' script code contains the "build/docker-linux-amd64" path. This needs changing to "build/docker-linux-arm" and can easily be achieved with a text editor, such as 'vim' or 'nano'. Alternatively, the 'sed' command can be used to change this setting within the 'docker-cli.SlackBuild' script file.
If you're installing on Slackware AArch64 then "build/docker-linux-amd64" needs changing to "build/docker-linux-arm64".
For Slackware AArch64 you can use the following 'sed' command
After running these commands, "-amd64" will be replaced with "-arm" or -arm64" and this can be verified by using another iteration of the 'sed' command and outputting line 71 within the 'docker-cli.SlackBuild' script file. Or 'grep' can be used, just as easily, to achieve the same results.
The process, commands used, and results, can be seen in the screenshot below.
If you can see that the 'build/docker-linux-amd64' section of code on line 71 has changed to 'build/docker-linux-arm' then the 'docker-cli.SlackBuild' script is good to go and ready to run.
Now we'll create the 'docker-cli' package by executing the 'docker-cli.SlackBuild' script.
Once the package has been built we can install it.
root@torq:/tmp# installpkg docker-cli-20.10.2-arm-1_SBo.tgz
That should result in the screenshot below.
The last package that's needed has been installed. Now we have all the software required to run Docker on our Slackware Linux system.
At this point you can skip to the "Running Docker on Slackware Linux" section to test and verify that the software is working as expected.
•
Installing Docker on Slackware Linux from pre-built SARPi packages
All the packages required to install Docker can be download from the SARPi package downloads page.
NB: The packages which are available from the SARPi package downloads page may be updated versions of those used in this Docker installation guide.
To get Docker installed and running on a Slackware Linux system using pre-built SARPi packages they should be installed in the order that they appear in the list below.
• libseccomp
• runc
• containerd
• tini
• docker-proxy
• docker
• docker-cli
Once all these SARPi packages have been installed on your Slackware system, it's time to think about Running Docker.
•
Running Docker on Slackware Linux
Installing all the packages to run Docker on Slackware Linux has created the dockerd initialisation script (Docker engine daemon), located at '/etc/rc.d/rc.docker'.
We can use the 'ls' command to view the status of the '/etc/rc.d/rc.docker' file.
The file has default user permissions of '-rw-r--r--' (0644) and needs making executable before it can be run. To make the '/etc/rc.d/rc.docker' file executable we use the 'chmod' command.
To start the Docker engine daemon (dockerd) we simply run the '/etc/rc.d/rc.docker' file that was just made executable and instruct it to start up the process.
Executing this file with the 'start' option has initialised the dockerd daemon. Incidentally, there are other '/etc/rc.d/rc.docker' usage options available with this script.
It's also possible to use 'restart', 'stop' and 'status' options, instead of 'start', to manage the '/etc/rc.d/rc.docker' (dockerd) daemon and view its current status. Hint: the '/etc/rc.d/rc.docker' usage options will do exactly as they say! This is always how the dockerd daemon is started, restarted, and stopped, manually on command line.
root@torq:~# /etc/rc.d/rc.docker stop
root@torq:~# /etc/rc.d/rc.docker status
Status of dockerd: stopped
It's also possible to automatically start the dockerd daemon at boot time by editing the '/etc/rc.d/rc.local' initialisation script and entering the example text code below into it.
This text code will start the Docker engine (dockerd daemon) whenever the Slackware system is booted, without needing to do it manually after each (re)boot.
We can verify that Docker is running by; using the '/etc/rc.d/rc.docker status' usage option, or by querying the process list for "docker" entries.
The screenshot below displays the output from using these various commands on the '/etc/rc.d/rc.docker' file and daemon process.
To see which version of Docker is installed we use the 'docker version' command.
The output shows that Docker 20.10.2 version is installed. Everything looks very good so far.
Testing Docker Containers
To do a test-run using Docker containers we can refer to the Docker Tutorial For Absolute Beginners installation page in the "Working with Docker Toolbox" section.
This results in what is shown on the screenshot below.
What it means is that Docker could not find an image named "hello-world" stored locally on the system. So, it downloaded (pulled) this image from an online repository and then ran it as a container. This very much indicates that Docker is working as expected.
We'll do another quick test and run 'busybox' in the same way, only with an echo value added.
This will not find the 'busybox' image on our system. So, again, the Docker image will be downloaded and ran as a container, and it will also include the echo command that we specified.
The screenshot displays the results exactly as we expected. Now we know that Docker is working perfectly.
To view a list of Docker containers running on the system the 'docker ps' command is used. In our case there are no containers currently active, so none will be displayed. To view a list of containers which exist on our system (active or not) the 'docker ps -a' command is used.
We can see that only two Docker containers can be found (with an 'Exited' status - which means they are not active) and these are the ones that we've just used for testing Docker.
To remove these test Docker containers, in order to start afresh, we will delete them using the 'docker rm <CONTAINER_ID>' command.
Now we have a clean Docker container list.
That's it! Docker has been installed, tested, and found to be working perfectly. All that's left to do from here is use it to gain more experience and hopefully learn a great deal about Docker as we go along.
•
Thanks!
Thank you for reading and taking part in this SARPi mini-project. We hope you enjoyed it and found it interesting and educational.
Thanks also to Patrick Volkerding, and the entire Slackware Team, for producing a truly wonderful OS. Without you, and the work you do, the SARPi Project would not exist.
If you have any questions or need help, visit the Slackware Linux Forum on Linux Questions. Or get in touch on the #SARPi IRC channel on irc.libera.chat.
•