0

Right now I have a custom image for ffmpeg, which has the burden of having to maintain the custom image. I was thinking of a way to do this more efficiently and came across init containers. I think init containers are a good solution to make sure that I don't have to maintain a custom image and because it imposes the separation of concerns principle.

In my deployment config, I made an init container where I retrieve the ffmpeg image from docker and copy it.

    kind: DeploymentConfig

    spec:
      initContainers:
        - name: ffmpeg
          image: 'docker.io/jrottenberg/ffmpeg:4.4-centos8'
          command:
            - cp
            - /usr/local/bin/ffmpeg
            - /opt/ffmpeg/
          resources: {}
          volumeMounts:
            - name: opt-ffmpeg
              mountPath: /opt/ffmpeg
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      containers:
          name: example
          image: example/example:v1
          volumeMounts:
            - name: ffmpeg
              mountPath: /opt/ffmpeg
      volumes:
        - name: ffmpeg
          emptyDir: {}

The problem is that ffmpeg is missing a few libraries. Ffmpeg is looking for shared libraries and is not able to find them. I know that static libraries provide everything, but I haven't found a good static library to use yet.

sh-4.4$ ldd ffmpeg 
    linux-vdso.so.1 (0x00007ffe5876a000)
    libnss_wrapper.so => /lib64/libnss_wrapper.so (0x00007f1f19b37000)
    libavdevice.so.58 => not found
    libavfilter.so.7 => not found
    libavformat.so.58 => not found
    libavcodec.so.58 => not found
    libavresample.so.4 => not found
    libpostproc.so.55 => not found
    libswresample.so.3 => not found
    libswscale.so.5 => not found
    libavutil.so.56 => not found
    libm.so.6 => /lib64/libm.so.6 (0x00007f1f197b5000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1f19595000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f1f191d0000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f1f18fcc000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f1f19d46000)

Does anyone know a way to link dynamic libraries? Or does anyone have a suggestion how I can use ffmpeg without a custom image?

Thanks in advance.

Tony
  • 21
  • 4
  • 2
    Can you edit the question to include a [mcve], including the image's Dockerfile, the YAML for the init container, and any actual error messages you're getting? (Make sure to include these details as text and not images, and directly in the question and not behind links.) Why are you trying to do this setup in an init container instead of compiling it into a Docker image? – David Maze Jan 13 '22 at 00:08
  • also, did you check if you're getting these errors in general for that image or just in openshift? might be a permission issue. of course please add any helping files or code as mentioned in the previous comment – Noam Yizraeli Jan 14 '22 at 18:05
  • @DavidMaze I don't have any error messages, there are just a few libraries that are missing whenever I look into the directory, which make ffmpeg unable to use for me. Within our organization, init containers are used often for utilities that are not present in the application image. For example, there is an init container which contains the AppDynamics image. Also I dont have any experience with docker and we have not discussed that possibility. Can you help me with a starting point for using docker? – Tony Jan 18 '22 at 13:12
  • @NoamYizraeli ffmpeg is just not usable for me in openshift. I don't have any issues with it outside of openshift. – Tony Jan 18 '22 at 13:13
  • Hi @Tony, following your asnwers to me and David, please check with what user and group permissions are you running when out side of openshift and inside it, usually stuff like this manifest from random user generation in openshift. check [this](https://cookbook.openshift.org/users-and-role-based-access-control/why-do-my-applications-run-as-a-random-user-id.html) for more info – Noam Yizraeli Jan 18 '22 at 14:21
  • You in general can't just copy binaries from one place to another, as you've noted you're missing shared libraries and you might be missing other artifacts too. You should install this in your image's Dockerfile, probably using the normal package manager. That will also give you the opportunity to test if `docker run` works in a local environment before going to the more complex Kubernetes setup. – David Maze Jan 18 '22 at 14:22

0 Answers0