Docker and nginx web server on router?

You can try exroot to move openwrt to USB drive

Sorry I cannot answer the performance quetions of docker on the router.

Thanks @alzhao, I was able to install extroot, mount a USB drive, and successfully install dockerd and luci-app-dockerman. However, I couldnā€™t get docker-compose installed. Error message:

Collected errors:
 * pkg_hash_check_unresolved: cannot find dependency python3-cryptography for python3-paramiko
 * pkg_hash_fetch_best_installation_candidate: Packages for python3-paramiko found, but incompatible with the architectures configured
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for docker-compose:
 * 	python3-cryptography
 * opkg_install_cmd: Cannot install package docker-compose.

Any chance this could be made available as that is how I configure docker apps. Thank you.

I mustā€™ve missed this post of yours. I know this may be off topic, but what how exactly should one use a Brume 2 device with my current setup? I do run wireguard on my the Flint so I can vpn home when I need to. Care to elaborate, @jdub? Thanks.

If youā€™ve already got a flint, a Brume is probably redundant, though I could give some reasons. It has more memory and storage, which would more easily let you do things like youā€™re considering (docker), though you can do them with extroot too. Theyā€™re cheap enough that you could get two and run a high availability setup, although thatā€™s some work with OpenWRT.

Personally I prefer to have my router and access points separate so I can upgrade either of them independently. Iā€™ve been running the same pfSense install (upgraded hardware and versions, obviously) for the last decade, and itā€™s been rock solid. Iā€™ve gone from a single OpenWRT access point to a 5 AP setup in that time, all while keeping the same basic routing configuration. You could do something similar with OpenWRT, though itā€™s a little more complicated with the variety of packages involved.

At the end of the day I standardized on a different platform that works well for me, but OpenWRT is the king of low power devices (I even run it on an embedded armv5 board in production at work!).

If you were actually going to go that route youā€™d probably be better off getting a cheap x86 board or something like a nanoPi 6S and virtualizing your setup (OpenWRT or one of the BSD alternatives). That way you can easily move setups between hardware setups. Can describe more if interested.

Thanks for the explanation. I do prefer simple setups over complicated setups, and lower energy footprint over higher energy :). Hoping flint can handle an nginx reverse proxy app via docker without issue. If not, I might explore a raspberry pi with openwrt and ax6 access point plugged in

Iā€™d probably consider something like a Brume 2 with stock ish OpenWRT over a rpi actually. Cheaper and more available, and two wired ports built in. But you can run what youā€™ve got for a while, Iā€™d think.

Problem with docker packages itself is they are really big.

As example I wanted to do this on a mochabin totally different brandā€¦ the amount on the partition was 104 mb as extroot, not really much.

but then even if you gonna use for example a usb stick to add storage to a gl-inet router its still difficult you need to know alot of commands.

Tl;tr: for those who want the difficult technical approach:

click to expand

Basicly what you want for package storage:

Mount one partition into /overlay, and /overlay is for docker itself readonly because its only ment for installing huge packages im not sure why its made like that, but pulling images on /overlay will fail.

Then you want to mount /opt/ with a second partition and this is for the use of docker, otherwise you will get vague errors and docker will not pull images, this hunted me in the past :yum:

Tools you need:
fdisk e2fsprogs kmod-fs-ext4 kmod-usb-storage blkid block-mount

First you login via ssh and check if the disk exists with ls /dev/ often its callled sd, or sda or even usb, use blkid to make sure, you can also try lsusb.

To format you use:
mkfs.ext4 /dev/<usb device> this will turn it into a ext4 device, you can also use other file systems but I believe ext4 is stablest.

to partition:
use fdisk /dev/sda its important you dont select the child partition but basicly the master, then press p to see any partitions if you see any type d this is to delete it, and if you want to add one you press n then it asks you the partition number and then it gives you two options to create a primary disk or extend its always the first one so 1.

Then it asks you the begin size, just press enter, and then it asks for the end size in where you add: +1G which means you create from 0 to 1gb a partition, this is enough for your packages, you may also can use +512m it depends what suits you.

Congrats you made partition 1, the same wizard is for partition 2 you only have to specify number 2 then when it asks for the drive, and also you donā€™t have to add anything like +1G as you gonna use the full end.

Edit totally forgot: when done, you write ā€˜wā€™ and press enter to write the partition layout and exit fdisk.

Now we need to mount them to docker and package managerā€¦

first we need to make a hold on the uuid table which we can read from blkid, your disk did not list?, then its likely you have to reformat the child partitions to ext4 with mkfs.ext4 /dev/sd.

Now import our disk table into block-mount by using:
block detect | uci import fstab

Then open fstab here with vi or nano: /etc/config/fstab

if correct you will see both of your partitions along with their uuid.

great!, now the only thing you have to do is:

add a section like this:

     config mount 'overlay'
         target '/overlay'
         uuid '<paste uuid from the sda1 partition>'

     config mount 'opt'
        target '/opt'
        uuid 'uuid from partition 2'

Then reboot, this should give you 1gb for packages from your usb device, and all the rest in /opt for docker, as for persistence im afraid you have to redo this everytime with a upgrade or maybe you can re-mount /overlay im not sure about thisā€¦

Sources:
[OpenWrt Wiki] Using storage devices

[OpenWrt Wiki] Fstab Configuration

[OpenWrt Wiki] Mounting Block Devices

2 Likes

The link I referenced above for extroot shows a step by step guide with all commands needed to get the USB drive up and running. Not as complicated as one would think.

Thanks.

1 Like

@alzhao Hi, wanted to follow up on getting docker-compose installed on the router. Would this be possible? Thank you.

Sorry, too many depends for docker-compose and I gave up.

Docker-compose and the depends has been added to the repo. It installs.

However didnā€™t test how it works.

3 Likes

Hi, did you ever get the docker daemon running? I get:

root@GL-AX1800:~# docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I have done the following:

  • Updated to firmware 4.2.1
  • extroot a USB stick using the official guide
  • Installed the dockerd, docker & luci-app-dockerman packages
  • Ran service dockerd start

When running dockerd, I get:
failed to start daemon: Devices cgroup isn't mounted

Any help / thoughts appreciated.

Thanks

@Vinhdizzo any ideas?
I only noticed the following error when installing (opkg install docker dockerd luci-app-dockerman):

Configuring btrfs-progsuci: Entry not found

The following error when running docker (dockerd):

failed to start daemon: Devices cgroup isn't mounted

See attached install.txt & dockerd.log for the full output

docker_install.zip (2.7 KB)

@alzhao I see you added dockerd to the repo for the AX1800. Any ideas why it is not working? Please see logs, above

Cgroups arenā€™t really built into openwrt.

But you can try this:

cgroupfs-umount
cgroupfs-mount

Thanks @beniamin - I now get

Your kernel does not support swap memory limit
Your kernel does not support cgroup blkio weight
Your kernel does not support cgroup blkio weight_device

rather than
Unable to find ā€¦

Which is fine if thatā€™s the answer but it doesnā€™t explain why @alzhao added dockerd to the AX1800 repo or how @Vinhdizzo got it working.

See attached for full logs
docker_070522.zip (2.3 KB)

Hi, I didnā€™t mean to ignore. I actually havenā€™t attempted the docker install as I used a USB 3.0 flash drive to expand space, but it messed up my wifi signal. I just ordered a USB 2.0 drive to replace and will continue my test.

Hi, thanks for getting back.
Iā€™m using a USB 3.0 drive no problem, although I havenā€™t tested what speed itā€™s actually running at

Iā€™m using this with an SSD and also had this flash drive working