Proxmox – Unify controller as Docker

 

 

 

Instead of a full Virtual Machine, only for running an Unifi Controller – I have created mine in a container as Docker on my Proxmox.

Log in to Proxmox and go to where you would store the templates, Select CT Templates, Then select Templates

Search for the templates you wish to use (Ubuntu22.04) anbd press Download

 

After the Templates are downloaded we can start creating the container, Select the Create CT to create new Container

 

Enter a Hostname, then enter the Password you’d like to use.
This password will be used to log in to the root user account. After all the settings
have been specified, select Next.
 Select the Template, then select Next to proceed.
Select the Disk Size for this container, then select Next.
Select the total Cores for the CPU, then select Next.
Set the total Memory, then select Next.

NOTE: Please keep in mind that this is the limit that this container can use.

Change the Network to use DHCP for IPv4 and IPv6 (unless you want to specify them manually), then select Next until you get to Confirm.

NOTE: We are skipping the DNS section, but you can change these settings if you’d like to use a DNS server different than the Proxmox host.

Confirm the settings, then select Finish to create the container!
Select the LXC Container we just created, then select Options and Edit the Features.


Enable keyctl, then select OK – and you can now start the container

Now you can start the container, login with user root and the password created (I normally also insert my SSH key – so I can login through SSH.  I always start by running: apt update && apt dist-upgrade -y && apt autoremove -y to secure the system is uptodate.

Next I install some needed packages (depending on who you are) : apt install mlocate net-tools docker.io curl -y – and after the system is updated I always reboot the machine.  Now you can a container you can reboot in seconds.

So now login to you new container – and create a file it unifi.sh – containing:

docker run -d \
–name=unifi-controller \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Etc/UTC \
-e MEM_LIMIT=1024 `#optional` \
-e MEM_STARTUP=1024 `#optional` \
-p 8443:8443 \
-p 3478:3478/udp \
-p 10001:10001/udp \
-p 8080:8080 \
-p 1900:1900/udp `#optional` \
-p 8843:8843 `#optional` \
-p 8880:8880 `#optional` \
-p 6789:6789 `#optional` \
-p 5514:5514/udp `#optional` \
-v /path/to/data:/config \
–restart unless-stopped \
lscr.io/linuxserver/unifi-controller:latest

Make it executeable by running : chmod +x unifi.sh  – and the afterwards run it – and it’ll the create the Docker and start it afterwards: ./unifi.sh – and after the script is done you should be able to connect to the Unifi Controller at https://IP.TO.THE.CONTROLLER:8443 and from here start creating your network as you like it. You can also install portainer or Kubernetes as GUI for running these Dockers.

Securing the docker-unifi to start if the Container is rebooted – we’ll use the service /etc/rc.local on on ubnt container – You’ll need to setup using rc.local which is not standard. but adding the startup command:

#!/bin/bash
#
## Starting the UBNT Docker
/usr/bin/docker start unifi-controller