simple unifi controller as you would install it on linux base
255
#!/bin/sh
# location in container:
# /app/startup_script.sh
# First update system
DEBIAN_FRONTEND=noninteractive apt-get update
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
# Fix Permissions - otherwise unifi controller will not start
chown -R unifi /var/lib/unifi /var/log/unifi /var/run/unifi
# start controller (IMPORTANT)
/usr/lib/unifi/bin/unifi.init start
# Make the server running
tail -f /dev/null
networks:
backend: # This is my network, you can replace it with your or use default bridge
external: true
services:
local_unificontroller:
image: nahaku/unifi-controller:latest
container_name: unificontroller
hostname: unificontroller
networks:
backend:
ipv4_address: 172.22.22.108
restart: always
ports:
# for devices adoption: "set-inform http://HOSIPorNAME:8080/inform"
- 8080:8080/tcp # Devices enrollment and management port
- 3478:3478/udp # TUN access for devices
- 8443:8443/tcp # I use proxy I so i do not need exposed
# - 10001:10001/udp # network device discovery
# - 1900:1900/udp #optional
# - 8843:8843 #optional
# - 8880:8880 #optional
# - 6789:6789 #optional
# - 5514:5514/udp #optional
environment:
- TZ=Europe/London
volumes:
# to keep your unifi controller data after container re-builds
- /opt/local_settings/unifi/:/unifidata
# Custom Startup script? make sure you add "chmod +x"
#- /path/to/startup_script.sh:/app/startup_script.sh
# labels if you use Traefik, you can omit this section completely if you do not use Traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.local_unificontroller.rule=Host(`unificontroller.domain.com`)"
- "traefik.http.routers.local_unificontroller.entrypoints=https"
- "traefik.http.routers.local_unificontroller.tls.certresolver=cloudflare"
- "traefik.http.routers.local_unificontroller.service=local_unificontroller-serv"
- "traefik.http.services.local_unificontroller-serv.loadbalancer.server.port=8443"
- "traefik.http.services.local_unificontroller-serv.loadbalancer.server.scheme=https"
FROM debian:latest
# Environment variables
ENV TZ="Europe/London"
# Update and install dependencies
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y curl gpg openjdk-17-jre-headless procps iputils-ping net-tools
# Set timezone and configure /etc/localtime link
RUN ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata && \
dpkg-reconfigure --frontend noninteractive tzdata
# Add UniFi repository and import its GPG key
RUN curl -s https://dl.ui.com/unifi/unifi-repo.gpg | tee /usr/share/keyrings/ubiquiti-archive-keyring.gpg >/dev/null && \
echo 'deb [signed-by=/usr/share/keyrings/ubiquiti-archive-keyring.gpg] https://www.ui.com/downloads/unifi/debian stable ubiquiti' | tee /etc/apt/sources.list.d/100-ubnt-unifi.list > /dev/null
# Add MongoDB repository and import its GPG key
RUN curl -s https://pgp.mongodb.com/server-7.0.asc | gpg --dearmor | tee /usr/share/keyrings/mongodb-org-server-7.0-archive-keyring.gpg >/dev/null && \
echo 'deb [arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-org-server-7.0-archive-keyring.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse' | tee /etc/apt/sources.list.d/mongodb-org-7.0.list > /dev/null
# Install MongoDB
RUN apt-get update && \
apt-get install -y mongodb-org && \
su -s /bin/bash -c "mongod --config /etc/mongod.conf --fork --bind_ip 127.0.0.1" mongodb
# Install Unifi Controller
RUN apt-get update && apt-get install -y unifi
# Ensure MongoDB data and UniFi data are persistent
RUN ln -s /usr/lib/unifi/data /unifidata
WORKDIR /unifidata
VOLUME [/unifidata]
# Prepare Startup script ( updates container and starts controller)
RUN mkdir /app
ADD /startup_script.sh /app
RUN chmod +x /app/startup_script.sh
# Close the MongoDB before we start it all
EXPOSE 8080/tcp 8443/tcp 8843/tcp 8880/tcp 10001/udp 3478/udp 5514/udp
# Start MongoDB and UniFi Controller
ENTRYPOINT /app/startup_script.sh
docker network create \
--driver=bridge \
--subnet=172.22.22.0/24 \
--gateway=172.22.22.1 \
--attachable=true \
--opt com.docker.network.bridge.name=backend \
backend
Content type
Image
Digest
sha256:6ba39d5ee…
Size
573.5 MB
Last updated
almost 2 years ago
docker pull nahaku/unifi-controller