Install libopencv-3.1.1 manually from JetPack-4.1.1 on Ubuntu-16.04 docker image

I’m trying to install libopencv-3.3.1 from the JetPack-4.4.1 into an Ubuntu-16.04 Docker image.

I get the following error while attempting it to install libopencv-3.3.1 from a local deb file:

libopencv : Depends: libavcodec57 (>= 7:3.4.2) but it is not installable or
                      libavcodec-extra57 (>= 7:3.4.2) but it is not installable
             Depends: libavformat57 (>= 7:3.4.2) but it is not installable
             Depends: libavutil55 (>= 7:3.4.2) but it is not installable
             Depends: libc6 (>= 2.27) but 2.23-0ubuntu10 is to be installed
             Depends: libstdc++6 (>= 6) but 5.4.0-6ubuntu1~16.04.10 is to be installed
             Depends: libswscale4 (>= 7:3.4.2) but it is not installable

Should I try using libopencv-3.3.1 from JetPack-3.3 instead, since that particular version has been built for Ubuntu-16.04, as opposed to the JetPack-4.4.1 version which has been built for Ubuntu-18.04?

Using libopencv-3.3.1 from JetPack-3.3 seems to work for a Ubuntu-16.04 docker image.

$ export URL=""
$ curl $URL/libopencv_3.3.1_t186_arm64.deb         -so libopencv_arm64.deb

$ apt-get install ./libopencv_arm64.deb

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libopencv' instead of './libopencv_arm64.deb'
The following additional packages will be installed:
  libjasper1 libtbb2
Suggested packages:
The following NEW packages will be installed:
  libjasper1 libopencv libtbb2
0 upgraded, 3 newly installed, 0 to remove and 14 not upgraded.
Need to get 197 kB/8929 kB of archives.
After this operation, 48.7 MB of additional disk space will be used.
Do you want to continue? [Y/n]

So, for building a working docker image for Ubuntu-16.04, I would have to use JetPack-4.4.1 for all the CUDA-10.0 stuff and resort to using JetPack-3.3 for the OpenCV-3.3.1 libraries and python bindings.

This problem won’t happen for an Ubuntu-18.04 docker image.

So the good news so far is that I’ve been able to successfully build docker images for ROS Kinetic for the Jetson AGX platform for both Ubuntu-16.04, with full support for OpenGL and CUDA acceleration inside docker containers. Most of the ROS samples that I’ve got appear to work so far. I’ll need to do some quick tests with some OpenCV samples, and also hold back the libopencv packages, so that they do not get over-written by the ros-kinetic-opencv-candidate package which also provides libopencv-3.3.1.

sudo apt-mark hold libopencv libopencv-dev libopencv-python libopencv-samples