pducharme / UniFi-Video-Controller

Docker for Unifi-Video Controller (Ubiquiti Networks)
200 stars 105 forks source link

Custom build docker image produces broken unifi video controller #198

Closed jeroenhe closed 3 years ago

jeroenhe commented 3 years ago

I have an issue with the unifi video controller where it won't start properly, specifically with a custom built image. Before anyone wonders why I would build my own custom image anyway when there is a working one, I did that to add customisations that allow me to install a custom webserver certificate. What is weird is that the image that was built 5 months ago works properly (pducharme/unifi-video-controller), but when I build it myself (based on presumably the exact same Dockerfile) it doesn't work properly. I suspect this is caused by something that has changed with the dependencies that are installed into the image via apt, because that's the only thing that is different for as far as I know.

Reproducing the issue

In a clean setup, this works:

mkdir -p unifi-video/data
mkdir -p unifi-video/videos
docker run \
      --name unifi-video \
      --cap-add DAC_READ_SEARCH \
      -p 10001:10001 \
      -p 1935:1935 \
      -p 6666:6666 \
      -p 7080:7080 \
      -p 7442:7442 \
      -p 7443:7443 \
      -p 7444:7444 \
      -p 7445:7445 \
      -p 7446:7446 \
      -p 7447:7447 \
      -v "$(pwd)/unifi-video/data:/var/lib/unifi-video" \
      -v "$(pwd)/unifi-video/data:/var/lib/unifi-video/videos" \
      --tmpfs /var/cache/unifi-video \
      -e TZ=Europe/Amsterdam \
      -e PUID=99 \
      -e PGID=100 \
      -e CREATE_TMPFS=no \
      -e DEBUG=1 \
      pducharme/unifi-video-controller

# After a little while, you can visit http://localhost:7080

But this does not (build the image yourself):

# Stop the previously started container, to prevent port conflicts:
docker stop unifi-video
docker rm unifi-video

git clone git@github.com:pducharme/UniFi-Video-Controller.git
cd UniFi-Video-Controller
git checkout 3.10.13
docker build -t unifi-video .
docker run \
      --name unifi-video \
      --cap-add DAC_READ_SEARCH \
      -p 10001:10001 \
      -p 1935:1935 \
      -p 6666:6666 \
      -p 7080:7080 \
      -p 7442:7442 \
      -p 7443:7443 \
      -p 7444:7444 \
      -p 7445:7445 \
      -p 7446:7446 \
      -p 7447:7447 \
      -v "$(pwd)/run/data/:/var/lib/unifi-video" \
      -v "$(pwd)/run/videos:/var/lib/unifi-video/videos" \
      --tmpfs /var/cache/unifi-video \
      -e TZ=Europe/Amsterdam \
      -e PUID=99 \
      -e PGID=100 \
      -e CREATE_TMPFS=no \
      -e DEBUG=1 \
      unifi-video

# Then it outputs:
java.lang.ClassFormatError: Illegal method name "new.super" in class com/ubnt/airvision/Main
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at org.apache.commons.daemon.support.DaemonLoader.load(DaemonLoader.java:151)
Cannot load daemon
java_load failed
Service exit with a return value of 3

My questions

petri3 commented 3 years ago

I have the same issue ! output : unifi-video-controller | 2021-03-16 11:56:56.796182 Waiting for mongodb to come online...Java VM created successfully unifi-video-controller | Class org/apache/commons/daemon/support/DaemonLoader found unifi-video-controller | Native methods registered unifi-video-controller | java_init done unifi-video-controller | Daemon loading... unifi-video-controller | java.lang.ClassFormatError: Illegal method name "new.super" in class com/ubnt/airvision/Main unifi-video-controller | at java.lang.ClassLoader.defineClass1(Native Method) unifi-video-controller | at java.lang.ClassLoader.defineClass(ClassLoader.java:756) unifi-video-controller | at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) unifi-video-controller | at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) unifi-video-controller | at java.net.URLClassLoader.access$100(URLClassLoader.java:74) unifi-video-controller | at java.net.URLClassLoader$1.run(URLClassLoader.java:369) unifi-video-controller | at java.net.URLClassLoader$1.run(URLClassLoader.java:363) unifi-video-controller | at java.security.AccessController.doPrivileged(Native Method) unifi-video-controller | at java.net.URLClassLoader.findClass(URLClassLoader.java:362) unifi-video-controller | at java.lang.ClassLoader.loadClass(ClassLoader.java:418) unifi-video-controller | at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) unifi-video-controller | at java.lang.ClassLoader.loadClass(ClassLoader.java:351) unifi-video-controller | at org.apache.commons.daemon.support.DaemonLoader.load(DaemonLoader.java:151) unifi-video-controller | Cannot load daemon unifi-video-controller | java_load failed unifi-video-controller | Service exit with a return value of 3

docker info :

Client:
 Debug Mode: false

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 16
 Server Version: 19.03.15
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ea765aba0d05254012b0b9e595e995c09186427f
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.14.138-rancher
 Operating System: RancherOS v1.5.8
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 2.949GiB
 Name: rancheros.domain.me
 ID: YM67:YQWD:62KO:Z2HT:TDCS:UBNX:DZQL:UHCD:7PHK:GRJO:VKNU:DMP7
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

docker-compose.yaml

version: '2'

services:
  unifi-video:
    image: "pducharme/unifi-video-controller"
    build: .
    container_name: unifi-video-controller
    cap_add:
        - DAC_READ_SEARCH
    ports:
        - 10001:10001
        - 1935:1935
        - 6666:6666
        - 7080:7080
        - 7442:7442
        - 7443:7443
        - 7444:7444
        - 7445:7445
        - 7446:7446
        - 7447:7447
    environment:
        - TZ=Europe/Brussels
        - PUID=<<UID>>
        - PGID=<<GID>>
        - CREATE_TMPFS=no
        - DEBUG=1
    volumes:
    - nfsUdata:/var/lib/unifi-video:nocopy
    - nfsUvideo:/var/lib/unifi-video/videos
    - cacheUvideo:/var/cache/unifi-video
    restart: always
    #    privileged: true

volumes:
  nfsUdata:
      #driver: nfs
      driver_opts:
        type: "nfs"
        o: "addr=<<IP>>,nolock,soft,rw"
        device: ":/volume/unifi-video/data/"

  nfsUvideo:
    #driver: nfs
    driver_opts:
      type: "nfs"
      o: "addr=<<IP>>,nolock,soft,rw"
      device: ":/volume/unifi-video/video/"

  cacheUvideo:
    driver_opts:
      type: tmpfs
      device: tmpfs

Tya for the support :-)

atkka commented 3 years ago
  * different openjdk java version? Yes: `1.8.0_265` vs `1.8.0_282`

I believe this is your issue, I restarted a non-docker version of unifi-video-controller yesterday and a java update broke the controller, I manually installed the old version and it worked fine after that.

jeroenhe commented 3 years ago
  * different openjdk java version? Yes: `1.8.0_265` vs `1.8.0_282`

I believe this is your issue, I restarted a non-docker version of unifi-video-controller yesterday and a java update broke the controller, I manually installed the old version and it worked fine after that.

Thank you for mentioning that. I'll have a try at fixing the specific version and report results back here.

jeroenhe commented 3 years ago

I've "downgraded" java to the specific version/release openjdk-8-jre-headless=8u162-b12-1 and now unifi-video boots again. There is one exception left, but it doesn't seem to matter much:

Exception in thread "EmsInitTask" java.lang.NullPointerException
        at com.ubnt.airvision.service.ems.C.void.new(Unknown Source)
        at com.ubnt.airvision.service.ems.C$1.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:748) 

So, the Dockerfile that now produces a working unifi-video server contains openjdk-8-jre-headless=8u162-b12-1 \ on line 29 instead of openjdk-8-jre-headless.

If anyone finds nice way to install the 1.8.0_265 version using apt, let me know. This issue is now fixed for me, so I'm closing it. In my opinion it's not worthy of a PR, unless we can find a nice way of installing the "correct" required Java version in a decent way.

jessereynolds commented 2 years ago

@jeroenhendricksen not exactly what you're after but I was able to revert the ubuntu xenial security update the broke my unifi video by first finding out the available versions:

# apt-cache policy openjdk-8-jre-headless
openjdk-8-jre-headless:
  Installed: 8u292-b10-0ubuntu1~16.04.1
  Candidate: 8u292-b10-0ubuntu1~16.04.1
  Version table:
 *** 8u292-b10-0ubuntu1~16.04.1 500
        500 http://au.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        100 /var/lib/dpkg/status
     8u77-b03-3ubuntu3 500
        500 http://au.archive.ubuntu.com/ubuntu xenial/main amd64 Packages

And then installing the older version:

# apt-get install openjdk-8-jre-headless:amd64=8u77-b03-3ubuntu3