Setting Up SSH and Docker Compose on OpenWrt Router

NO.1
All In One

Having tried cloud servers (x86) and played with Raspberry Pi (arm64), I want to try an All In One.

This means that networking, NAS, and other systems and services are all on one host, ready to use upon boot.

The main selling point is portability; there’s no need to set up a separate soft router, a separate Home Assistant, a separate lightweight NAS, or a separate xxx.

Each time there’s a power outage or other issues, it causes service disruptions. Additionally, as the number of hosts increases, the routers, switches, sockets, cables, and cooling issues also multiply, leading to significantly higher electricity bills.

All In One attempts to pack some commonly used services into a credit card-sized box, taking up minimal space in the room and fitting easily in a bag.

Currently, I have chosen the NanoPi R4S.

It offers a balanced performance, better than the R2S, and cheaper than the R6S, while also having one more network port than the Raspberry Pi 4B (currently in use, cannot compare).

This article temporarily uses the R2S as a substitute; I will update it with R4S later.

NO.2
SSH

Click on System (left menu), then click on Management Rights (submenu).

Check the box to allow root login.

Setting Up SSH and Docker Compose on OpenWrt Router

Then log in using the terminal.

The default router address for this article is 192.168.1.1.

The SSH login username and password are the OpenWrt username and password.

ssh [email protected]

The first time you log in, you will see a prompt like the one below; type ‘yes’ and press enter to confirm.

You will then be prompted to enter the password; input the password and press enter to confirm.

Setting Up SSH and Docker Compose on OpenWrt Router

You will enter SSH.

Some basic information will be displayed.

Setting Up SSH and Docker Compose on OpenWrt Router

Enter the root directory to view the directories.

Create a custom directory for subsequent operations; in this article, I will create a folder named ‘dsx2016’.

Setting Up SSH and Docker Compose on OpenWrt Router

Check the Docker version.

docker --version

Check the Docker Compose version.

docker-compose --version

You can see that Docker is installed by default, but Docker Compose is not.

Setting Up SSH and Docker Compose on OpenWrt Router

In fact, in the service-docker plugin, you can see the relevant information about Docker.

This is a plugin that comes pre-installed with the OpenWrt firmware, providing a Docker environment.

Click on Containers in the lower left corner.

Setting Up SSH and Docker Compose on OpenWrt Router

You will see the container interface.

Currently, I have not installed any Docker containers.

Setting Up SSH and Docker Compose on OpenWrt Router

Click on Add in the lower left corner.

You will see the Docker settings page.

Setting Up SSH and Docker Compose on OpenWrt Router

However, I am not quite used to this interface.

I prefer using Docker Compose.

Once Docker Compose is installed, I can continue to install Portainer.

Portainer is an open-source container management platform that allows for visual operations of all services and clear visibility of all data.

NO.3
Installing Docker Compose

First, check the chip architecture of R2S/R4S.

Use the following command.

uname -a

You should see ‘aarch64’.

AArch64 is an execution state of the ARMv8 architecture.

Setting Up SSH and Docker Compose on OpenWrt Router

Refer to the previous article on installing Docker Compose.

<<Raspberry Pi 4B (Raspberry Pi For NAS): Installing Docker and Docker Compose>>

You can see that the download address suffix corresponds to the architecture category above; select AArch64.

Copy the corresponding download address from the email.

Setting Up SSH and Docker Compose on OpenWrt Router

Execute the download.

curl -SL https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-linux-aarch64 -o /bin/docker-compose

Setting Up SSH and Docker Compose on OpenWrt Router

Grant file permissions.

sudo chmod 777 /usr/local/bin/docker-compose

Setting Up SSH and Docker Compose on OpenWrt Router

Check the version number.

docker-compose --version

Setting Up SSH and Docker Compose on OpenWrt Router

Note that the commands above differ from those for Raspberry Pi.

This is because Raspberry Pi uses Ubuntu Server 22.04, where the bin directory is in usr/local/bin.

However, I checked the root directory of my R2S and found the bin directory in the root, so the commands also differ; this is something to note.

If your bin folder location is different from mine, you need to modify the above command to your bin location to install Docker Compose correctly.

NO.4
Tips

OpenWrt is a Linux operating system designed for embedded devices.

Essentially, it is still a Linux system, but highly modular and specific to certain scenarios.

Thus, some Linux commands and logics still apply to OpenWrt, such as ssh, docker (common commands like cd, ls, etc.).

By solving Docker and Docker Compose, many open-source applications related to NAS can be deployed in Docker Compose, just like the lightweight NAS collection for Raspberry Pi.

In the future, I will attempt to deploy NAS applications on OpenWrt to achieve All In One.

Moreover, OpenWrt not only supports Docker but also has a rich set of plugins. These plugins not only provide applications but can also implement some functionalities from the network layer that Docker cannot achieve, so utilizing plugins effectively is also a key point.

END.

Recommended Reading

Dozens of open-source Docker applications are compiled below.

<<Raspberry Pi 4B (Raspberry Pi): Home Multifunctional NAS>>

Leave a Comment