Skip to content

Instantly share code, notes, and snippets.

@marfillaster
Last active December 30, 2023 14:03
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save marfillaster/9fa1a9571d4d93b2992977d33d99b1a9 to your computer and use it in GitHub Desktop.
Save marfillaster/9fa1a9571d4d93b2992977d33d99b1a9 to your computer and use it in GitHub Desktop.
Running Unifi Network Controller as a container in MikroTik ROSv7 RB5009

Requirement

  • USB flash drive - this is where the container filesystem will be persisted

Set-up docker bridge network

/interface bridge add name=docker

Set-up veth to be used by container

/interface veth add address=172.16.2.2/24 gateway=172.16.2.1 name=veth1
/interface bridge port add bridge=docker interface=veth

Assign IP to the docker bridge

/ip/address add address=172.16.2.1/24 interface=docker network=172.16.2.0

You may optionally set up firewall rules to isolate the docker network.

Configure registry

/container config set registry-url=https://registry-1.docker.io tmpdir=disk1/cache

Set memory limits

/container envs add key=MEM_LIMIT name=unifi value=512
/container envs add key=MEM_STARTUP name=unifi value=256

Probably can still be tuned down.

Define the container

/container add remote-image=linuxserver/unifi-controller:latest envlist=unifi_controller interface=veth1 logging=yes root-dir=disk1/unifi

Do not mount /config. AS of 7.4rc2, mount still has permission issue. Since we are using root-dir (the router will run out of memory otherwise), the container will persist between restarts anyway.

Start the container

/container/start 0

Monitor container starup state

/container/print

Add static DNS entries

/ip/dns/static
# default set-inform host
add address=172.16.2.2 name=unifi
# host to use in browser
add address=172.16.2.2 name=unifi.lan

Browse admin panel https://unifi.lan:8443

Credit to @bergnetwork https://youtu.be/2Rq1Dnj2p8E

Update

  • v7.4 stable does not include container support
@klausbfrederiksen
Copy link

Don't you need to get the container?
container/add remote-image=linuxserver/unifi-controller:latest interface=veth1 root-dir=disk1/unifi

@marfillaster
Copy link
Author

@klausbfrederiksen good catch! Hilarious I missed the most important part lol

@markwell-ch
Copy link

@marfillaster is this setup running stable for you? No reboots due to out of memory conditions? (I'm using RouterOS 7.8)

@marfillaster
Copy link
Author

I stopped experimenting on this. But yeah it always get OOM'ed and the boot time is atrocious.

@markwell-ch
Copy link

Wow, thanks for the fast reply 🚀 Sad that it's not running stable on RB5009.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment