Skip to main content
All CollectionsRouters
Setup and Install Docker Netclient on OpenWRT
Setup and Install Docker Netclient on OpenWRT

User Netclient seamlessly on OpenWRT via Docker

Dennis Tadlip avatar
Written by Dennis Tadlip
Updated over a week ago

Prerequisite: Expand Storage

Installing large packages on OpenWRT can be challenging due to the limited storage space typically available on many routers. While there are several methods to address this limitation, this guide will focus on expanding the root filesystem using an external storage volume, such as a USB device or disk.

This demonstration uses OpenWRT hosted in a cloud infrastructure, but the instructions should also apply to physical routers running OpenWRT. The following steps assume you already have shell access to your OpenWRT device. For more detailed information, please refer to the official OpenWRT extroot documentation: https://openwrt.org/docs/guide-user/additional-software/extroot_configuration.

Step 1: Install Required Packages

First, update the package lists and install the necessary packages:

opkg update
opkg install block-mount kmod-fs-ext4 e2fsprogs parted kmod-usb-storage

Step 2: Attach and Identify the Volume

Identify the connected storage device:

ls -l /sys/block

Step 3: Partition and Format the Disk

Partition and format the disk with ext4:

DISK="/dev/sda"
parted -s ${DISK} -- mklabel gpt mkpart extroot 2048s -2048s
DEVICE="${DISK}1"
mkfs.ext4 -L extroot ${DEVICE}

Step 4: Configure the Extroot Mount Entry

Create the extroot mount entry:

eval $(block info ${DEVICE} | grep -o -e 'UUID="\S*"')
eval $(block info | grep -o -e 'MOUNT="\S*/overlay"')
uci -q delete fstab.extroot
uci set fstab.extroot="mount"
uci set fstab.extroot.uuid="${UUID}"
uci set fstab.extroot.target="${MOUNT}"
uci commit fstab

Step 5: Configure a Mount Entry for the Original Overlay

Create a mount entry for the original overlay:

ORIG="$(block info | sed -n -e '/MOUNT="\S*\/overlay"/s/:\s.*$//p')"
uci -q delete fstab.rwm
uci set fstab.rwm="mount"
uci set fstab.rwm.device="${ORIG}"
uci set fstab.rwm.target="/rwm"
uci commit fstab

Step 6: Transfer the Current Overlay to the External Drive

Copy the contents of the current overlay to the external drive:

mount ${DEVICE} /mnt
tar -C ${MOUNT} -cvf - . | tar -C /mnt -xf -

Step 7: Reboot the Device to Apply Changes

Reboot your device:

reboot

Step 8: Modify /etc/config/fstab

Update the /etc/config/fstab configuration:

config 'global'
option anon_swap '0'
option anon_mount '0'
option auto_swap '1'
option auto_mount '1'
option delay_root '5'
option check_fs '0'

config mount
option target '/overlay'
option device '/dev/sda1'
option fstype 'ext4'
option options 'rw,sync'
option enabled '1'
option enabled_fsck '0'

This configuration sets up your external drive as the primary storage for installing packages.

Step 9: Reboot Your Router

Reboot the router to finalize the changes:

reboot

Install Docker

Refer to the OpenWRT Docker guide: https://openwrt.org/docs/guide-user/virtualization/docker_host for more details. Generally, you may need to run containers as specific users, requiring the creation of new users, groups, and setting up the appropriate folder permissions. However, for simplicity in this demo, we’ll use the root user.

Install Docker:

opkg install dockerd docker

Install WireGuard

The safest way to install WireGuard on OpenWRT is via the Web GUI:

1. Navigate to System -> Software.

2. Click the Update lists… button.

3. Search for WireGuard.

4. Install wireguard-tools and luci-proto-wireguard (for Web GUI integration).

5. Reboot the router.


Join Netmaker Network Via Docker

In the Netmaker UI, add a host by selecting Docker. Copy the docker run command (omitting sudo) and run it on your OpenWRT device.

Did this answer your question?