Assuming you are using the official PHP Docker image...
# ---------------------------------------------------------------
# PHP Extension: Gearman
# Download Gearman PECL extension for Gearman supporting PHP 7
RUN apt-get -y --allow-unauthenticated install \
libgearman-dev
RUN cd /tmp \
&& git clone https://github.com/wcgallego/pecl-gearman.git \
&& cd pecl-gearman \
&& git checkout gearman-2.0.3 \
&& phpize \
&& ./configure \
&& make -j$(nproc) \
&& make install \
&& rm -r /tmp/pecl-gearman \
&& docker-php-ext-enable gearman
I recently updated my
install-php-extensions
script; it now supports installing the gearman PHP extension (as well as 92 other PHP extensions) with a single line:More info here: https://github.com/mlocati/docker-php-extension-installer