Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

NO.1
Content Correction

First, the firmware recommended in the previous article needs to be corrected.

Reference Article

<<OpenWrt Router (NanoPi For NAS All In One R2S): Firmware Installation and Expansion (Squashfs)>>

The author sirpdboy provides a free version of the firmware, which can install Docker and Docker Compose, but cannot install Dockerd. Therefore, you can see the version of Docker, but cannot start and use Docker (the plugin does not have Docker by default).

There are Docker versions and full plugins, which are not free. Therefore, for daily network routing, you can try this firmware, but if you want to use Docker-related applications, the free version firmware is not recommended.

NO.2
Changing Firmware

The specific firmware is not provided for download here. Please consult the seller’s customer service when buying R2S and R4S.

Theoretically, the following expansion and installation of Docker is universal on OpenWrt, with little difference.

I have tested three firmware versions.

One is the free firmware from Enshan sirpdboy (unable to install dockerd dependencies, unable to start Docker).

One is NanoPi-R2S-rk3328 (gihutb) (has Docker, crashes every few minutes, possibly due to power supply or firmware issues).

One is the firmware from R2S itself (should be consistent with the seller) (currently has expanded Docker disk space, comes with Docker plugin, can install Docker Compose, and has successfully tested several applications, successfully pulling images over 5GB, indicating that corresponding expansion is also not a problem).

The expansion in the previous article did not achieve the effect of expanding Docker (this article is also corrected).

NO.3
Flashing Firmware

Prerequisites

Software: balenaEtcher (Download Link:https://etcher.balena.io/)

Hardware: TF card (128GB) (with corresponding USB card reader)

After installing balenaEtcher, open the software and insert the card reader to read the TF card.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Select Firmware

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Select Disk

Note that this needs special attention. Carefully check the size of the selected disk and confirm that it is consistent with the size of the TF card.

Avoid selecting other USB drives or the local disk, which may cause formatting the computer’s own system.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Click Flash to start writing the firmware to the TF card

Password is required on Mac

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Wait for the flashing to complete

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

After successful input, you will see a pop-up prompt that cannot be recognized

Click ignore or exit (it is recommended to click exit on Mac)

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

This is the completed interface

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

NO.4
Starting the System

Insert the TF card into R2S, then insert the power cable and turn on the power.

At this time, it is recommended not to insert the network cable into the R2S’s Wlan and Lan ports to avoid affecting other routers.

Wait for the system red light to stabilize, indicating that the system has successfully started.

Note

This article directly connects the R2S Lan (local area network) to the computer’s network cable and finds that the network cannot be recognized.

However, when the R2S Lan (local area network) network cable is connected to a dynamically configured router, and then the computer connects to the router’s wifi, it can normally access OpenWrt.

So the firmware itself is not a problem, but to conduct tests and settings, you still need to prepare a router in advance.

If your Lan and computer network cable can connect normally, then the above precautions can be skipped.

The default management backend address for this firmware is:http://192.168.100.1

Default account: root Default password: password

Access the management backend

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Enter the main interface

You can see that there is a Docker menu on the left (Docker is installed by default).

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

NO.5
Firmware Expansion (Docker)

The expansion here is only for Docker.

Click the menu, System -> Disk Management

For TF, it is generally identified as /dev/mmcblk0, click the corresponding modification on the right.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Find the disk with the largest remaining space at the bottom, which is about 118GB in this article.

Click the new button on the right.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

After creating, an additional mmcblk0p3 appears.

Click the corresponding format on the right.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Select to format as ext4 (make sure to select ext4).

Click format and wait for the formatting to succeed.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

After successful formatting, the page will automatically refresh.

You can see that the file system of mmcblk0p3 has changed to ext4.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Click the menu, System -> Mount Point

Click Generate Configuration

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

You can see the mount point list, with an additional item marked in red below.

Click the corresponding edit on the right.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Check Enable

However, this pop-up does not show the option (/opt or /opt/docker).

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Click Custom Area

Input /opt, then press Enter.

Click Save

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Then click Save and Apply at the bottom of the page.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

The page will automatically refresh.

You can see that the mounted system has added the area marked in red.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Click Disk Management

You can also see (confirm) the mounted disk marked in red.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

It is worth noting that expanding Docker will not expand the software package or other system areas.

Therefore, this article only focuses on Docker expansion.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

NO.6
Installing Docker and Compose

Use the terminal to ssh into OpenWrt.

ssh [email protected]

You may encounter an error.

Host key for 192.168.100.1 has changed and you have requested strict checking.

This is because you have previously accessed the same OpenWrt ssh, but after flashing the firmware again, the ssh key and hash corresponding to the same IP address do not match. You need to clear the cache and then recreate the key.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Clear ssh cache

ssh-keygen -R 192.168.100.1

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

SSH again

You need to create a key for the first time, just type yes.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Continue to enter the password

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

SSH into OpenWrt

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Enter the /opt directory

cd /opt

Check Docker version

docker --version

You can see that the default version is V20.10.22.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Check Docker Compose version

docker-compose --version

Not installed by default.

-bash: docker-compose: command not found

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Install Docker Compose

Download Docker Compose (aarch64)

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

Copy the following text (the highlighted code seems to have a space issue with the address).

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

After successful download, grant permissions

chmod 777 /bin/docker-compose

Then check the Docker Compose version

docker-compose --version

You can see that it was installed successfully.

Docker Compose version is v2.20.3.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

NO.7
Installing Portainer

Considering that OpenWrt does not have conventional Linux commands and dependency libraries, a visual container management platform is needed.

Since the expanded disk directory is /opt.

So this article puts all Docker-related content under the /opt directory.

Create the /opt/dsx2016/docker/portainer folder

mkdir -p /opt/dsx2016/docker/portainer

Create the docker-compose.yml configuration file

vi docker-compose.yml

Press the i key to enter edit mode.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Right-click to copy and paste the following content

version: "3"
services:
  portainer:
    image: portainer/portainer-ce:linux-arm64
    container_name: portainer
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./ortainer_data:/data
    ports:
      - "3036:8000"
      - "3037:9000"
      - "3038:9443"

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Press Esc

Type :wq!

Press Enter to exit edit mode and save.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Pull the image and start the service

docker-compose up

You may see an error

open /opt/docker/tmp/GetImageBlob2396860121: no such file or directory

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

In this case, there are two solutions

1. Try restarting Docker first

2. If restarting Docker does not work, try restarting OpenWrt.

Restart Docker

Click the menu, Docker -> Overview

Click Stop, then Restart

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Then try starting docker-compose again

This time it started successfully.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Open Port

This article’s portainer requires opening port 3037

Click the menu, Network – Firewall – Communication Rules

Click the Add button at the bottom of the page

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Unless there are special needs

Just input the name and target port.

Then click Save

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

You can see that a rule has been added to the page.

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

NO.8
Using Portainer

Access IP: Port

Input username and password to create an admin account

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Click to use the local environment

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

Enter the local environment list

Expanding Docker Disk Space and Using Docker on OpenWrt for NanoPi R2S

The subsequent usage can refer to the official documentation.

NO.9
Tips

So far

  1. Replaced the firmware of R2S

  2. Set the expansion of Docker disk

  3. Installed Docker Compose dependencies

  4. Deployed the visual container management platform portainer

  5. Solved inexplicable Docker issues (restarted Docker)

Note

If you encounter issues like freezing or rebooting, please first confirm the read and write speed of the TF card (above C10) and the power supply (5v3a), then check the temperature and heat dissipation, and finally disable some plugins that may cause exceptions.

1G of memory is suitable for some non-data automation services.

Such as MQTT gateway, message notification, PT download, static web page login, and subsequent deployments and tests.

END

Recommended Reading

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

Leave a Comment