I installed Wkhtmltopdf on Alpine Docker with the following command:
apk add --no-cache wkhtmltopdf
However when I try to run wkhtmltopdf I get:
/usr/bin/wkhtmltopdf "test.html" "test.pdf"
Cannot mix incompatible Qt library (version 0x50c03) with this library (version 0x50c00)
Aborted (core dumped)
How can I fix that?
EDIT:
Seems like the issue is that some other package installs not compatable qt version. Here's my Dockerfile:
RUN apk --no-cache update \
&& apk --no-cache upgrade \
&& apk add --no-cache \
mysql-client \
php7-mysqli \
php7-pdo \
freetype \
libpng \
freetype-dev \
libpng-dev \
jpeg-dev \
libjpeg \
libjpeg-turbo-dev \
wget \
zlib-dev \
ttf-freefont \
fontconfig \
xvfb \
libxrender-dev \
gettext \
gettext-dev \
libxml2-dev \
gnu-libiconv-dev \
autoconf \
g++ \
git \
bash \
wkhtmltopdf
You cannot install wkhtmltopdf from alpine repositories starting of 3.15 version https://pkgs.alpinelinux.org/packages?name=wkhtmltopdf&branch=edge&repo=&arch=&maintainer=
If you want to use wkhtmltopdf in the newer alpine (3.17 below). You can copy bin files from other images like https://github.com/Surnet/docker-wkhtmltopdf and install related libraries.
Here is Dockerfile:
FROM surnet/alpine-wkhtmltopdf:3.16.2-0.12.6-full as wkhtmltopdf
FROM php:8.2-fpm-alpine3.17 AS app
# wkhtmltopdf install dependencies
RUN apk add --no-cache \
libstdc++ \
libx11 \
libxrender \
libxext \
libssl1.1 \
ca-certificates \
fontconfig \
freetype \
ttf-droid \
ttf-freefont \
ttf-liberation \
# more fonts
;
# wkhtmltopdf copy bins from ext image
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/libwkhtmltox.so /bin/
# install php extensions, apache/nginx etc.
Related
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" ]
I'm using Docker in a developement environment. I have two pc, both with same OS (kubuntu 20.04) and same docker version.
In one the dockerfile build without errors, in the other fails with
$ docker build -t letsjump/mydockername -f docker-data/webserver73/Dockerfile .
#...lot of compile output...
configure: error: unrecognized options: --with-freetype, --with-jpeg, --with-freetype, --with-webp
The command '/bin/sh -c curl -sL https://deb.nodesource.com/setup_12.x | bash - && apt-key update && DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" install $CUSTOM_BUILD_DEPS $PHPIZE_DEPS sendmail git mariadb-client openssh-client nano netcat linkchecker nodejs build-essential libzip-dev libz-dev wget unixodbc odbcinst unixodbc-dev gnupg libwebp-dev libonig-dev --no-install-recommends && npm -g install npm#latest && docker-php-ext-configure gd --with-freetype --with-jpeg --with-freetype --with-webp && docker-php-ext-configure bcmath && docker-php-ext-configure calendar && docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr && docker-php-ext-install gd intl pdo_mysql mysqli mbstring opcache zip bcmath calendar soap && pecl install memcached-3.1.5 && echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini && printf "\n" | pecl -d preferred_state=beta install xdebug' returned a non-zero code: 1
In both hosts I have the same OS (kubuntu 20.04 desktop) and almost the same Docker version.
In this host the dockerfile build succesfully:
$ docker --version
Docker version 19.03.5, build 633a0ea838
In this other not:
$ docker --version
Docker version 19.03.12, build 48a66213fe
This is the dockerfile:
# Dockerfile (c) letsjump 2018
FROM php:7.3-apache
MAINTAINER letsjump <letsjump#xxx>
WORKDIR /
COPY ./docker-data/webserver73/ /
RUN chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "/usr/local/bin";
RUN chmod -R +xr "/usr/local/bin/";
EXPOSE 80
EXPOSE 443
RUN useradd -ms /dev/null dbmaker
RUN chown -R dbmaker:dbmaker /home/dbmaker
# define build dependency lists
# inherited from PHP base image:
# PHPIZE_DEPS=autoconf dpkg-dev file g++ gcc libc-dev libpcre3-dev make pkg-config re2c
ENV CUSTOM_BUILD_DEPS \
unzip \
libmemcached-dev \
libicu-dev \
libfreetype6-dev \
libjpeg-dev \
libjpeg62-turbo-dev \
libxml2-dev \
zlib1g-dev \
libpng-dev
# list of other packages which could be deinstalled at the end
ENV CUSTOM_REMOVE_LIST cpp \
cpp-4.9 \
g++-4.9 \
gcc-4.9 \
libgcc-4.9-dev \
libhashkit-dev \
libsasl2-dev \
libstdc++-4.9-dev
RUN apt-get update && apt-get install -my gnupg
# Install system packages for PHP extensions recommended for Yii 2.0 Framework
# Install PHP extensions required for Yii 2.0 Framework
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
apt-key update && \
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" install \
$CUSTOM_BUILD_DEPS \
$PHPIZE_DEPS \
sendmail \
git \
mariadb-client \
openssh-client \
nano \
netcat \
linkchecker \
nodejs \
build-essential \
libzip-dev \
libz-dev \
wget \
unixodbc \
odbcinst \
unixodbc-dev \
gnupg \
libwebp-dev \
libonig-dev \
--no-install-recommends && \
npm -g install npm#latest && \
docker-php-ext-configure gd --with-freetype --with-jpeg --with-freetype --with-webp && \
docker-php-ext-configure bcmath && \
docker-php-ext-configure calendar && \
docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr && \
docker-php-ext-install gd \
intl \
pdo_mysql \
mysqli \
mbstring \
opcache \
zip \
bcmath \
calendar \
soap && \
# printf "\n" | pecl -d preferred_state=beta install xdebug
pecl install memcached-3.1.5 && \
echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini && \
printf "\n" | pecl -d preferred_state=beta install xdebug
# apt-get remove -y $PHPIZE_DEPS $CUSTOM_BUILD_DEPS $CUSTOM_REMOVE_LIST && \
# dpkg --purge $(dpkg -l | awk '/^rc/ { print $2 }') && \
# apt-get clean && \
# rm -rf /usr/src/php* && \
# rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#set -x \
# && cd /usr/src/php/ext/odbc \
# && phpize \
# && sed -ri 's#^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$##&#g' configure \
# odbc
# docker-php-ext-configure odbc --with-unixODBC=/usr --with-dbmaker=/home/dbmaker/5.2 && \
# docker-php-ext-configure odbc --with-unixODBC=/usr --with-dbmaker=/home/dbmaker/5.2 --with-adabas=no && \
# Install less-compiler
RUN npm install -g \
less \
lesshint \
uglify-js \
uglifycss
ENV PHP_USER_ID=33 \
PHP_ENABLE_XDEBUG=1 \
VERSION_COMPOSER_ASSET_PLUGIN=^1.4.6 \
VERSION_PRESTISSIMO_PLUGIN=^0.3.10 \
PATH=/var/www/:/root/.composer/vendor/bin:$PATH \
TERM=linux \
COMPOSER_ALLOW_SUPERUSER=1 \
GITHUB_API_TOKEN=${GITHUB_API_TOKEN}
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin \
--filename=composer --version=1.10.16 && \
composer global require --optimize-autoloader \
"fxp/composer-asset-plugin:${VERSION_COMPOSER_ASSET_PLUGIN}" \
"hirak/prestissimo:${VERSION_PRESTISSIMO_PLUGIN}" && \
composer global dumpautoload --optimize && \
composer clear-cache
RUN chown -R 1000:33 /var/www
# Install Yii framework bash autocompletion
RUN curl -L https://raw.githubusercontent.com/yiisoft/yii2/master/contrib/completion/bash/yii \
-o /etc/bash_completion.d/yii
# enabling specific apache2 modules
# enabling specific apache2 modules
RUN a2enmod rewrite && \
service apache2 restart
WORKDIR /var/www
Yes, the dockerfile is probably a mess, with a lot of adds on the fly. But why it compiles in one host and in the other not?
UPDATE
After reading the reasonable answer of aankhen, I emptied the docker-data/webserver73 folder which in any case did not contain any relevant code except one apache virtualhost and one xdebug.ini configuration file in their relative folders.
The build failed again with the same error as above.
I also want to point out that the wevserver73 folder contains the exact same files as the one on the other host with the same owner and rights.
I would expect failures to happen sporadically and periodically with this dockerfile. Why? Because you haven't pinned the versions of the majority of tools you're installing. You implicitly install the latest version of a bunch of GNU/Linux libraries and then explicitly install the latest version of npm and you follow this up by using npm to install the latest version of a bunch of javascript modules. I can see that you pin the versions of some libs, but to guarantee repeatability you have to pin everything.
Also, as #Aankhen said in the comments, you also have a copy command that is copying files from the local filesystem, which could contain anything and again is unlikely to result in a portable repeatable image.
The solution to this is a) pin everything, or b) use a registry to share an image that has been built once and rely on a pinned version of that. Generally, banks and large corporations require the pinning solution, and less regulated industries often go with the registry solution.
I answer to my question:
As Software-engineer said in his answer, pin, pin, pin.
In this case it was the PHP's mantainers (questionable) choice to change the Debian release within a minor version of the docker image (php:7.3-apache). Here they switched from stretch to buster.
So the new pulled php:7.3-apache image had a completely different OS and different dependent library and behaviors.
So, as Software-engineer said, the right and the fastest solution to this problem is to pin the PHP image to a tag related to the distribution: php:7.3-apache-stretch.
The slower and unstable solution, in case you want to use the unpinned version, is to adapt the GD configure options to the new release:
...
docker-php-ext-configure gd --with-gd --with-webp-dir --with-jpeg-dir \
--with-png-dir --with-zlib-dir --with-freetype-dir && \
...
taking care to include the necessary libraries first: libfreetype6-dev, libjpeg-dev and libjpeg62-turbo-dev
But this will require a manual pull from the server for any host that has a non recent build of the same image.
I have a docker instance setup from which I am using moviepy.editor.VideoFileClip to edit urls that come from a google cloud instance.
Locally, I have no problem doing this at all and can run:
from moviepy.editor import VideoFileClip
vfc = VideoFileClip('https://storage.googleapis.com/<bucket>/<mp4 name>')
...
However, in the docker instance, I am having problems accessing the file via moviepy, with the error:
Failed to resolve hostname storage.googleapis.com: Name or service not known
In the same python shell, i can run:
import urllib.request
urllib.request.urlretrieve('https://storage.googleapis.com/<bucket>/<mp4 name>', '/tmp/file.mp4')
And it works perfectly. Any idea what's going wrong?
Python Version: Python 3.7.3
Moviepy Version: moviepy==0.2.3.5
Platform Name: Alpine
Platform Version: Linux fe434704cf18 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 Linux
Dockerfile:
FROM jrottenberg/ffmpeg:4.1-alpine as ffmpeg
FROM python:3.7-alpine3.8
RUN apk update && apk upgrade && \
apk add --no-cache --update \
libgcc \
libstdc++ \
curl \
ca-certificates \
libcrypto1.0 \
libssl1.0 \
libgomp \
bash \
expat \
git \
openblas \
musl \
ffmpeg \
ghostscript \
file \
imagemagick
COPY --from=ffmpeg /usr/local /usr/local
WORKDIR /
COPY requirements.txt ./
RUN apk add --no-cache jpeg-dev zlib-dev postgresql-libs postgresql-dev && \
apk add --no-cache --virtual .build-deps gcc g++ build-base linux-headers \
ca-certificates python3-dev libffi-dev libressl-dev && \
ln -s /usr/include/local.h /usr/include/xlocale.h && \
apk add py-numpy && \
pip install pip --upgrade && \
pip install numpy && \
pip install --no-cache-dir -r requirements.txt && \
apk --purge del .build-deps
RUN rm requirements.txt
COPY ./docker/imagemagick.policy.xml etc/ImageMagick-6/policy.xml
COPY . .
# Run celery.py when the container launches
CMD ["celery", "worker", "-A", "a.celery", "--loglevel=info"]
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
I was running php7 on alpine without a hitch for the last week till today when I rebuilt my image and now nothing works. I get the errors:
/ # apk add php7
ERROR: unsatisfiable constraints:
php7 (missing):
required by: world[php7]
for every package , extension I was trying to install and that previously worked. Here's the RUN command I was using to setup php7:
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk update && \
apk upgrade && \
apk add --update \
php7-mcrypt \
php7-soap \
php7-openssl \
php7-gmp \
php7-pdo_odbc \
php7-json \
php7-dom \
php7-pdo \
php7-zip \
php7-mysqli \
php7-sqlite3 \
php7-pdo_pgsql \
php7-bcmath \
php7-gd \
php7-odbc \
php7-pdo_mysql \
php7-pdo_sqlite \
php7-gettext \
php7-xmlreader \
php7-xmlrpc \
php7-bz2 \
php7-iconv \
php7-pdo_dblib \
php7-curl \
php7-ctype \
php7-fpm
All the above extensions installed flawlessly last week. What I'm I missing?
Proof the packages do exist: https://pkgs.alpinelinux.org/packages?name=php7-*&branch=&repo=&arch=&maintainer=
Package php7 has been moved from the testing to the community repository, so you have to replace http://dl-cdn.alpinelinux.org/alpine/edge/testing with http://dl-cdn.alpinelinux.org/alpine/edge/community.
You should use the official PHP 7 Alpine image on DockerHub.
Then, per the image documentation, use the docker-php-ext-install command in your Dockerfile:
FROM php:7-fpm-alpine
RUN apk update \
&& apk add libmcrypt-dev \
&& docker-php-ext-install mcrypt mysqli pdo_mysql \
&& rm /var/cache/apk/*
This may initially look a little strange, but it works and is the officially supported Docker approach.
We provide the helper scripts docker-php-ext-configure,
docker-php-ext-install, and docker-php-ext-enable to more easily
install PHP extensions.
DockerHub - PHP