docker buildkit opencv compilation - docker

I have a Dockerfile which compiles opencv for quite a while. Recently I decided to try out buildkit (for cross compilation). However, with buildkit the opencv compilation fails. With the following error:
#9 130.0 [ 87%] Linking CXX shared library ../../lib/libopencv_imgcodecs.so
#9 130.5 [ 87%] Built target opencv_imgcodecs
#9 130.5 [ 87%] Generating src/moc_window_QT.cpp
#9 130.5 [ 87%] Generating qrc_window_QT.cpp
#9 130.5 standard input:0: Note: No relevant classes found. No output generated.
#9 130.5 RCC: Error in '/opencv/modules/highgui/src/window_QT.qrc': Cannot find file 'files_Qt/Milky/48/28.png'
#9 130.5 make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:78: modules/highgui/qrc_window_QT.cpp] Error 1
#9 130.5 make[1]: *** [CMakeFiles/Makefile2:1684: modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
#9 130.5 make: *** [Makefile:163: all] Error 2
I tried stopping the build after the git clone to see if the file files_Qt/Milky/48/28.png exists inside the container and it does. Moreover, if I start the compilation process from the interactive shell in the container, the compilation process succeeds.
So it seems the compilation only fails if it is part of the docker build.
Does anybody know more details about how buildkit works and if this could have an impact on the compilation process?
Here is a minimal example of the build command and Dockerfile:
DOCKER_BUILDKIT=1 docker build --no-cache --progress=plain -t "buildkit_error:latest" -f Dockerfile .
FROM ubuntu:20.04
WORKDIR /
# Setup apt repositories
RUN \
apt update && \
apt install -y --no-install-recommends \
wget \
software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
apt install -y --fix-broken && \
apt update && \
apt upgrade -y && \
apt dist-upgrade -y && \
apt remove -y python3 && \
apt clean && \
apt autoremove -y && \
apt autoclean -y
# Install apt packages
# ORDER ALPHABETICALLY!
RUN \
apt install -y --no-install-recommends \
build-essential \
clang-10 \
cmake \
cpio \
git \
libdrm-dev \
libcairo2-dev \
libomp-10-dev \
llvm-10-dev \
openssh-client \
pkg-config \
python3.6-dev \
python3.6-distutils\
python3.6-minimal \
python3-pip \
qt5-default
# Install pip dependencies
# ORDER ALPHABETICALLY!
RUN python3.6 -m pip install --no-cache-dir \
numpy==1.16.1 \
setuptools==59.6.0 \
wheel==0.37.1
RUN \
ln -sf /usr/bin/python3.6 /usr/bin/python3 && \
ln -sf /usr/bin/python3 /usr/bin/python
ENV opencv=3.4.3
RUN git clone --branch $opencv --depth 1 https://github.com/opencv/opencv.git
RUN ls -al /opencv/modules/highgui/src/files_Qt/Milky/48
# build opencv from source
RUN \
mkdir opencv/build && cd opencv/build && cmake -DBUILD_TIFF=ON \
-DCMAKE_C_COMPILER=clang-10 \
-DCMAKE_CXX_COMPILER=clang++-10 \
-DENABLE_FAST_MATH=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_opencv_java=OFF \
-DWITH_CUDA=OFF \
-DENABLE_CXX11=ON \
-DWITH_OPENGL=ON \
-DWITH_OPENCL=ON \
-DWITH_IPP=ON \
-DWITH_TBB=ON \
-DWITH_EIGEN=ON \
-DWITH_V4L=OFF \
-DWITH_GTK=ON \
-DWITH_GTK_2_X=ON \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_opencv_apps=OFF \
-DBUILD_JAVA=OFF \
-DBUILD_PROTOBUF=OFF \
-DBUILD_PACKAGE=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_opencv=OFF \
-DBUILD_opencv_dnn=OFF \
-DBUILD_opencv_java_bindings_generator=OFF \
-DBUILD_opencv_shape=OFF \
-DBUILD_opencv_stitching=OFF \
-DBUILD_opencv_superres=OFF \
-DBUILD_opencv_ts=OFF \
-DBUILD_opencv_video=OFF \
-DBUILD_opencv_videoio=OFF \
-DBUILD_opencv_videostab=OFF \
-DBUILD_opencv_world=OFF \
-DBUILD_opencv_ml=OFF \
-DBUILD_opencv_photo=OFF \
-DWITH_1394=OFF \
-DWITH_FFMPEG=OFF \
-DWITH_GSTREAMER=OFF \
-DWITH_IMGCODEC_HDR=OFF \
-DWITH_IMGCODEC_PXM=OFF \
-DWITH_IMGCODEC_SUNRASTER=OFF \
-DWITH_JASPER=OFF \
-DWITH_OPENCVAMDBLAS=OFF \
-DWITH_OPENCVAMDFFT=OFF \
-DWITH_OPENEXR=OFF \
-DWITH_OPENNI=OFF \
-DWITH_OPENNI2=OFF \
-DWITH_OPENVX=OFF \
-DWITH_VTK=OFF \
-DWITH_V4L=OFF \
-DWITH_QUIRC=OFF \
-DWITH_QT=ON \
-DBUILD_opencv_calib3d=ON \
-DBUILD_opencv_core=ON \
-DBUILD_opencv_python3=ON \
-DBUILD_opencv_flann=ON \
-DBUILD_opencv_python_binding_generator=ON \
-DBUILD_opencv_highgui=ON \
-DBUILD_opencv_imgcodecs=ON \
-DBUILD_opencv_features2d=ON \
-DBUILD_opencv_imgproc=ON \
-DWITH_OPENMP=ON \
-DWITH_PNG=ON \
-DWITH_HALIDE=OFF .. && \
make -j6 && make install

After a lot of investigation, I finally stumbled upon this ticket:
https://gitlab.archlinux.org/archlinux/archlinux-docker/-/issues/32
The comments gave me the idea that the kernel might be the problem. I upgraded the kernel and that seemed to have resolved the problem.
Hopefully this helps someone else in the future.

Related

GCC compilation within docker with "-j"

I got strange errors while compiling my project within the docker container when I am using -j option of make.
The errors look like this:
/root/projects/obj/linux_debug/src/myos_make/libmyos.a: error adding symbols: Cannot allocate memory
/usr/protobuf-3.9.2/lib/libprotobuf.a: error adding symbols: Bad address
Compiling the same project inside the container without -j and outside the container with -j passes ok.
The Dockerfile :
#
# This docker must be built from projects/src folder as context
#
FROM ubuntu:18.04 as base
# copy the dockerfile to make it possible to keep track of the cntent of the image
COPY ./docker_build/docker_files/Dockerfile.ubuntu18.04-builder $HOME/.
# Disable Prompt During Packages Installation
ARG DEBIAN_FRONTEND=noninteractive
# Update Ubuntu Software repository
RUN apt update -y && apt upgrade -y
# Install base utils
RUN apt install -y \
nano \
wget \
sudo \
curl \
&& apt clean -y
# Install additional packages needed for build.
RUN apt install -y \
nasm \
pkg-config \
bc \
python \
python3 \
python3-pip \
sshpass \
libapr1 \
libapr1-dev \
&& apt clean -y
RUN apt install -y \
rpm \
libaio-dev \
libnuma-dev \
numactl \
valgrind \
openssl \
libssl-dev \
ldap-utils \
libldap2-dev \
libncurses5-dev \
libncursesw5-dev \
uuid-dev \
ncurses-base \
expat \
libfuse-dev \
cmake \
build-essential \
autotools-dev \
autoconf \
automake \
doxygen \
linux-headers-4.15.0-173-generic \
g++-multilib \
lib32z1-dev \
libasan4 \
software-properties-common \
libtool \
unzip \
xsltproc \
&& apt clean -y
RUN ln -s /usr/bin/doxygen /bin/doxygen
# install GCC compiler
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y \
&& apt update -y\
&& apt install gcc-10 -y \
&& apt install g++-10 -y \
&& apt clean -y && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 --slave /usr/bin/g++ g++ /usr/bin/g++-10 && \
update-alternatives --config gcc
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py && \
python get-pip.py
RUN ln -sf /usr/local/bin/pip2 /usr/bin/pip
RUN pip install \
pyyaml \
jinja2 \
gcovr
FROM base as env-prepare
COPY external/protobuf /protobuf
RUN cd protobuf && ./build_proto.sh
FROM base as builder
COPY --from=env-prepare /usr/protobuf-3.9.2/ /usr/protobuf-3.9.2/
COPY --from=env-prepare /usr/protobuf-c-1.3.2/ /usr/protobuf-c-1.3.2/
COPY docker_build/docker-image-release /etc/docker-image-release
ARG UID=1000
USER ${UID}
# This entrypoint is to make everything run inside bash, so the devtools script will alway run before the command
ENTRYPOINT [ "/bin/bash", "-c" ]

Dockerfile not correctly installing dependencies

I am having an issue with installing dependencies with a Dockerfile. The image builds successfully, but when I attempt to test some of the dependencies installed in the Dockerfile below, they do not seem to be found. I am new to creating Dockerfiles so I am not sure if I am missing something. This may having something to do with environment variables? For example, I install sl as a test to confirm that something is not right. When a access a shell of my running image, running 'sl' returns "Command not found". Please let me know what I am doing wrong.
Here is my Dockerfile that I am using to build an image:
#FROM specifies the parent image from which we will construct our own custom image. This tomcat image contains a limited dist of Ubuntu, Tomcat9, and JRE11 ("temurin" is just a limited version of Java)
FROM tomcat:9-jre11-temurin
#add a maintainer label to the image
LABEL maintainer="Kerrick Cavanaugh - kerrickcavanaugh#ufl.edu"
#SciPy, Pandas, Numpy, other deps
RUN apt-get update && \
yes | apt-get -qq -y install \
git \
build-essential \
software-properties-common \
# python-dev \
python3 \
python3-dev \
python-dev \
libssl-dev \
# libffi-dev \
libxml2-dev \
libxslt1-dev \
apt-utils \
zlib1g-dev \
pip \
python3-pip \
sl \
gfortran \
libopenblas-dev \
liblapack-dev \
wget
# add /root/.local/bin to python path (causing warnings)
RUN python3 -c "import sys; sys.path.append('/root/.local/bin');"
RUN pip3 install --upgrade pip && pip3 install -vvv \
wheel \
matplotlib \
ipython \
jupyter \
sympy \
cython \
et-xmlfile==1.0.1 \
imbalanced-learn==0.5.0 \
imblearn==0.0 \
jdcal==1.4.1 \
joblib==0.14.0 \
numpy==1.16.4 \
scipy==1.3.1 \
openpyxl==2.6.4 \
pandas==0.24.2 \
python-dateutil==2.8.0 \
pytest==4.6.3 \
pytest-cov==2.7.1 \
pytz==2019.3 \
scikit-learn==0.21.3 \
six==1.12.0 \
xlrd==1.2.0
#R
RUN apt update && echo 'Y' | apt upgrade && \
#removed sudo from next 4
echo 'Y' | apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common && \
echo 'Y' | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 && \
echo 'Y' | add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/' && \
echo 'Y' | apt install r-base && \
R --version
#MATLAB???
#FSL
COPY ./aidp_docker/fslinstaller.py /usr/local/tomcat
#printf '36' | <-- for keyboard
#removed sudo
RUN apt-get update && apt-get -qq install python2
RUN { echo; echo '36'; } | python2 /usr/local/tomcat/fslinstaller.py -E -v -q > /dev/null
#AFNI
RUN cd && \
curl -O https://raw.githubusercontent.com/afni/afni/master/src/other_builds/OS_notes.linux_ubuntu_20_64_a_admin.txt && \
curl -O https://raw.githubusercontent.com/afni/afni/master/src/other_builds/OS_notes.linux_ubuntu_20_64_b_user.tcsh && \
curl -O https://raw.githubusercontent.com/afni/afni/master/src/other_builds/OS_notes.linux_ubuntu_20_64_c_nice.tcsh && \
#removed sudo
bash OS_notes.linux_ubuntu_20_64_a_admin.txt 2>&1 | tee o.ubuntu_20_a.txt && \
tcsh OS_notes.linux_ubuntu_20_64_b_user.tcsh 2>&1 | tee o.ubuntu_20_b.txt
#dcm2niix
RUN curl -fLO https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_lnx.zip
#ANTsR, ANTsRCore, ITKR
RUN git clone https://github.com/stnava/ITKR.git && \
git clone https://github.com/ANTsX/ANTsRCore.git && \
git clone https://github.com/ANTsX/ANTsR.git && \
R -e 'install.packages(c("Rcpp", "RcppEigen", "magrittr"))' && \
R CMD INSTALL ITKR && \
R CMD INSTALL ANTsRCore && \
R CMD INSTALL ANTsR
#COPY the specified folder structure and associated scripts to /usr/local/tomcat
COPY ./aidp_docker/ /usr/local/tomcat
#COPY wAIDP.war to the image
COPY ./wAIDP.war /usr/local/tomcat/webapps
#build complete
RUN echo 'Build complete!'
#runs the Docker image
CMD ["catalina.sh", "run"]

Docker openCV installation Issues

I'm currently trying to run an application using Docker but get the following error message when I start the application:
error while loading shared libraries: libopencv_highgui.so.4.4: cannot open shared object file: No such file or directory
I assume that something is going wrong in the docker file and that the installation is not complete or correct. Therefore I have added the section about OpenCV at the end of the post.
Did I miss an important step or an error in the dockerfile?
FROM nvidia/cuda:10.2-devel-ubuntu18.04 as TOOLKITS
RUN apt-get update && apt-get install -y apt-utils
# Install additional packages
RUN apt-get install -y \
build-essential \
bzip2 \
checkinstall \
cmake \
curl \
gcc \
gfortran \
git \
pkg-config \
python3-pip \
python3-dev \
python3-numpy \
nano \
openexr \
unzip \
wget \
yasm
FROM TOOLKITS as GIT_PULLS
WORKDIR /
RUN git clone https://github.com/opencv/opencv.git
RUN git clone https://github.com/opencv/opencv_contrib.git
FROM GIT_PULLS as OPENCV_PREPERATION
RUN apt-get install -y \
libgtk-3-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libxvidcore-dev \
libx264-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libatlas-base-dev \
libtbb2 \
libtbb-dev \
libdc1394-22-dev
FROM OPENCV_PREPERATION as OPENCV_CMAKE
WORKDIR /
RUN mkdir /opencv/build
WORKDIR /opencv/build
RUN cmake \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DINSTALL_C_EXAMPLES=ON \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DWITH_TBB=ON \
-DWITH_V4L=ON \
-DOPENCV_GENERATE_PKGCONFIG=ON \
-DWITH_OPENGL=ON \
-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-DOPENCV_PC_FILE_NAME=opencv.pc \
-DBUILD_EXAMPLES=ON ..
FROM OPENCV_CMAKE as BUILD_OPENCV_MAKE
RUN make -j $(nproc)
RUN make install
FROM TOOLKITS
COPY --from=XXX /opencv /opencv
COPY --from=XXX /opencv_contrib /opencv_contrib
I was facing the same issue before when installing OpenCV in Docker with Python image. You probably don't need this much dependencies but it's an option. I will have a lightweight version that fits my case. Please give a try for the following code:
Heavy-loaded version:
FROM python:3.7
RUN apt-get update \
&& apt-get install -y \
build-essential \
cmake \
git \
wget \
unzip \
yasm \
pkg-config \
libswscale-dev \
libtbb2 \
libtbb-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libavformat-dev \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip install numpy
WORKDIR /
ENV OPENCV_VERSION="4.1.1"
# install opencv-python from its source
RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip \
&& unzip ${OPENCV_VERSION}.zip \
&& mkdir /opencv-${OPENCV_VERSION}/cmake_binary \
&& cd /opencv-${OPENCV_VERSION}/cmake_binary \
&& cmake -DBUILD_TIFF=ON \
-DBUILD_opencv_java=OFF \
-DWITH_CUDA=OFF \
-DWITH_OPENGL=ON \
-DWITH_OPENCL=ON \
-DWITH_IPP=ON \
-DWITH_TBB=ON \
-DWITH_EIGEN=ON \
-DWITH_V4L=ON \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=$(python3.7 -c "import sys; print(sys.prefix)") \
-DPYTHON_EXECUTABLE=$(which python3.7) \
-DPYTHON_INCLUDE_DIR=$(python3.7 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-DPYTHON_PACKAGES_PATH=$(python3.7 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
.. \
&& make install \
&& rm /${OPENCV_VERSION}.zip \
&& rm -r /opencv-${OPENCV_VERSION}
RUN ln -s \
/usr/local/python/cv2/python-3.7/cv2.cpython-37m-x86_64-linux-gnu.so \
/usr/local/lib/python3.7/site-packages/cv2.so
RUN apt-get --fix-missing update && apt-get --fix-broken install && apt-get install -y poppler-utils && apt-get install -y tesseract-ocr && \
apt-get install -y libtesseract-dev && apt-get install -y libleptonica-dev && ldconfig && apt install -y libsm6 libxext6 && apt install -y python-opencv
Lightweight version:
FROM python:3.7
RUN apt-get update -y
RUN apt-update && apt install -y libsm6 libxext6
For my case, I ended up using the heavy-loaded version just to save some hassle and both versions should work fine. For your reference, please also see this link and thanks to Neo Anderson's great help.
I also had lots of issues in this process, and found this repository:
https://github.com/janza/docker-python3-opencv
Clone or download this and add the additional dependencies and files according to your requirement.
apt-get update -y
apt install -y libsm6 libxext6
apt update
pip install pyglview
apt install -y libgl1-mesa-glx

Docker build fails with dependency issues even though I am satisfying them

I'm looking for ideas as to why this is failing.
I've done the same steps on my host and they work well, the packages I'm calling out provide the needed dependencies.
Build Command:
docker build -t testbuild .
DockerFile:
FROM registry.redhat.io/rhel7:latest
RUN yum install -y yum-utils
RUN yum-config-manager --enable \
EPEL_7_EPEL_7 \
Community_mysql-connectors-community \
Community_mysql-tools-community \
Community_mysql57-community \
rhel-7-server-extras-rpms/x86_64 \
rhel-7-server-optional-rpms/7Server/x86_64 \
rhel-7-server-rh-common-rpms/7Server/x86_64 \
rhel-7-server-rpms/7Server/x86_64 \
rhel-server-rhscl-7-rpms/7Server/x86_64
RUN true \
&& yum install -y \
cairo \
yum-utils\
collectd \
openldap-devel \
rrdtool \
gcc \
rrdtool-devel \
pyrrd \
rrdtool-python \
python-ldap \
wget \
pycairo-devel \
pycairo \
python-devel \
collectd-nginx \
findutils \
rrdtool \
logrotate \
memcached \
nginx \
nodejs \
npm \
redis \
pkgconfig \
sqlite \
expect \
git \
python3\
python3-devel\
libffi-devel \
postgresql-devel \
postgresql-devel \
mysql-community-client \
mysql-community-libs \
mysql-community-common \
mysql-community-libs-compat
RUN yum clean all
RUN pip3 install \
virtualenv\
# && /usr/bin/easy_install virtualenv \
&& /usr/local/bin/virtualenv /opt/graphite \
&& . /opt/graphite/bin/activate \
&& pip3 install \
PyMySQL \
django==1.11.24 \
django-statsd-mozilla \
fadvise \
gunicorn \
msgpack-python \
redis \
rrdtool \
python-ldap \
mysqlclient \
psycopg2
The error I am getting is ERROR: Command errored out with exit status 1:
command: /opt/graphite/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] =
'"'"'/tmp/pip-install-67zlal6a/rrdtool/setup.py'"'"';
file='"'"'/tmp/pip-install-67zlal6a/rrdtool/setup.py'"'"';f=getattr(tokenize,
'"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"',
'"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))'
egg_info --egg-base pip-egg-info
cwd: /tmp/pip-install-67zlal6a/rrdtool/
Complete output (5 lines):
/tmp/tmp_python_rrdtoolfr1k715h/test_rrdtool.c:2:17: fatal error: rrd.h: No such file or directory
#include
^
compilation terminated.
Error: Unable to compile the binary module. Do you have the rrdtool header and libraries installed?
---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for
full command output.
But I've ensured the files exist with the yum-installed packages.
I've commented out this package and then I get a mysql_config error which I also don't get on my current test host. Which leads me to believe something is going wrong earlier in the build.
Any Ideas?
Don't have access to RHEL repository, so I tried with centos 7 and was having same issues.
But installing these additional packages helped to successfully build image:
RUN yum install -y epel-release
RUN yum install -y python36-pip
RUN yum install -y mysql mysql-devel
RUN yum install -y python36-devel
Here is final DockerFile:
FROM centos:7
RUN yum install -y yum-utils
RUN yum-config-manager --enable \
EPEL_7_EPEL_7 \
Community_mysql-connectors-community \
Community_mysql-tools-community \
Community_mysql57-community \
rhel-7-server-extras-rpms/x86_64 \
rhel-7-server-optional-rpms/7Server/x86_64 \
rhel-7-server-rh-common-rpms/7Server/x86_64 \
rhel-7-server-rpms/7Server/x86_64 \
rhel-server-rhscl-7-rpms/7Server/x86_64
RUN true \
&& yum install -y \
cairo \
yum-utils\
collectd \
openldap-devel \
rrdtool \
gcc \
rrdtool-devel \
pyrrd \
rrdtool-python \
python-ldap \
wget \
pycairo-devel \
pycairo \
python-devel \
collectd-nginx \
findutils \
rrdtool \
logrotate \
memcached \
nginx \
nodejs \
npm \
redis \
pkgconfig \
sqlite \
expect \
git \
python3\
python3-devel\
libffi-devel \
postgresql-devel \
postgresql-devel \
mysql-community-client \
mysql-community-libs \
mysql-community-common \
mysql-community-libs-compat
RUN yum install -y epel-release
RUN yum install -y python36-pip
RUN yum install -y mysql mysql-devel
RUN yum install -y python36-devel
RUN yum clean all
RUN pip3 install \
virtualenv\
&& /usr/local/bin/virtualenv /opt/graphite \
&& . /opt/graphite/bin/activate \
&& pip3 install \
PyMySQL \
django==1.11.24 \
django-statsd-mozilla \
fadvise \
gunicorn \
msgpack-python \
redis \
rrdtool \
python-ldap \
mysqlclient \
psycopg2

How to install ffmpeg in a docker container

I'm using aeneas python module which uses ffmpeg. I install ffmpeg in the dockerfile as follows:
RUN apt-get update && apt-get install -y ffmpeg
Now when I run the program, it fails with: aeneas.ffprobewrapper.FFPROBEPathError: Unable to call the 'ffprobe' ffprobe executable : [Errno 2] No such file or directory: 'ffprobe' and aeneas.audiofile.AudioFileProbeError: Unable to call ffprobe executable. So my question is, how can I successfully use ffmpeg in a docker container? I'm running Ubuntu 16.04.
Install fresh ffmpeg version from sources in docker container on Debian 9/10/Ubuntu.
You can replace 4.2.2 version to any other available on https://ffmpeg.org/releases/
# Compile and install fresh ffmpeg from sources:
# See: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
RUN apt-get update -qq && apt-get -y install \
autoconf \
automake \
build-essential \
cmake \
git-core \
libass-dev \
libfreetype6-dev \
libsdl2-dev \
libtool \
libva-dev \
libvdpau-dev \
libvorbis-dev \
libxcb1-dev \
libxcb-shm0-dev \
libxcb-xfixes0-dev \
pkg-config \
texinfo \
wget \
zlib1g-dev \
nasm \
yasm \
libx265-dev \
libnuma-dev \
libvpx-dev \
libmp3lame-dev \
libopus-dev \
libx264-dev \
libfdk-aac-dev
RUN mkdir -p ~/ffmpeg_sources ~/bin && cd ~/ffmpeg_sources && \
wget -O ffmpeg-4.2.2.tar.bz2 https://ffmpeg.org/releases/ffmpeg-4.2.2.tar.bz2 && \
tar xjvf ffmpeg-4.2.2.tar.bz2 && \
cd ffmpeg-4.2.2 && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="$HOME/bin" \
--enable-libfdk-aac \
--enable-gpl \
--enable-libass \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree && \
PATH="$HOME/bin:$PATH" make -j8 && \
make install -j8 && \
hash -r
RUN mv ~/bin/ffmpeg /usr/local/bin && mv ~/bin/ffprobe /usr/local/bin && mv ~/bin/ffplay /usr/local/bin
It could be faulty library, then this should help:
apt-get install ffmpeg libavcodec-extra-53
If not it can be path problem:
$ffmpeg = FFMpeg\FFMpeg::create(array(
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe'));
The similar issue resolved here: https://github.com/PHP-FFMpeg/PHP-FFMpeg/issues/172
in the last message on the bottom of the website.
You can do it if you have linux. Or anywhere you can install X (haven't tested it). Basic idea is that linux is using X11, so you can fart out X data to your host machine's X server.
Dockerfile
FROM ubuntu:latest
RUN apt-get update -qq && apt-get install ffmpeg -y
ENTRYPOINT ["ffplay"]
Build that with
docker build -t ffplay:latest .
play.sh
docker run \
--rm \
-u `id -u` \
-e DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$HOME/Desktop:/media" \
ffplay:latest \
-i /media/test.mp4

Resources