4

We've configured a Dockerfile containing the following code snippet:

ENV MEMCACHE_VERSION=8.0 \
    MEMCACHED_VERSION=3.2.0

############## END ENVIRONMENT VARIABLES ###############
########################################################

RUN apt-get update && apt-get install -y --no-install-recommends \
    zlib1g-dev \
    zlib1g \
    libmemcached11 \
    libmemcachedutil2 \
    libmemcached-dev \
    libmagickwand-dev 

RUN pecl install memcache-$MEMCACHE_VERSION && \
    pecl install memcached-$MEMCACHED_VERSION && \
    pecl install imagick

But yesterday starting from 17:00 after running docker compose up --build -d --force-recreate all of a sudden the following error started occuring. Note: This did not happen before 17:00, the whole day it worked just fine.

 => ERROR [builder 3/3] RUN pecl install memcache-8.0 &&     pecl install memcached-3.2.0 &&     pecl install imagick                   15.1s

#0 15.03 checking for libmemcached location... configure: error: memcached support requires libmemcached. Use --with-libmemcached-dir=<DIR> to specify the prefix where libmemcached headers and library are located
#0 15.06 ERROR: `/tmp/pear/temp/memcached/configure --with-php-config=/usr/local/bin/php-config --with-libmemcached-dir=no --with-zlib-dir=no --with-system-fastlz=no --enable-memcached-igbinary=no --enable-memcached-msgpack=no --enable-memcached-json=no --enable-memcached-protocol=no --enable-memcached-sasl=yes --enable-memcached-session=yes' failed
------
failed to solve: process "/bin/sh -c pecl install memcache-$MEMCACHE_VERSION &&     pecl install memcached-$MEMCACHED_VERSION &&     pecl install imagick" did not complete successfully: exit code: 1

I want to repeat that we haven't changed anything in the Dockerfile and this started happening to my other colleagues docker environments as well as if something has changed in the libmemcached or memcached modules since yesterday around this time.

What we've already tried:

  • Using the option behind the commands -with-libmemcached-dir=/usr/include/libmemcached
  • Updating Docker Desktop
  • Install libmemcached manually on the docker container and uncommenting the memcache/memcached/imagick installs code below to see if libmemcached was installer for real. libmemcached was present in the folder /usr/include/libmemcached. Running the memcached installation right after resulted in the same error
  • Freak out and stare at the screen hoping it will go away
1
  • and what is the business related question or issue in here?
    – djdomi
    Commented Jun 15, 2023 at 18:00

2 Answers 2

8

What version of PHP are you using? We had this issue ourselves, and it seemed to be tied to the Docker image tag php:8.1-fpm.

https://hub.docker.com/layers/library/php/8.1-fpm/images/sha256-4bb4c92e2b4ed0f58997835c29c206f2e9c8f1e3ee29677cf1fd86affda1e99d?context=explore

This image is in turn built on Debian, which just a few days ago had a new version released (12 - Bookworm, vs the prior 11 - Bullseye). Bookworm jumped the libmemcached-dev version from 1.0.18 to 1.1.4, but for some reason 1.1.4 doesn't seem to be installing properly, thus pecl can't find the right header file.

https://packages.debian.org/bullseye/libmemcached-dev https://packages.debian.org/bookworm/libmemcached-dev

We were able to resolve the build issue by changing our tag from php:8.1-fpm to php:8.1-fpm-bullseye to go back to the Bullseye Debian version, where libmemcached-dev 1.0.18 continues to work just fine.

3
  • Thank you so much for your comment, we're using PHP version 8.2 , which is using php:8.2-fpm. I'm gonna look into it now
    – IT-Girl
    Commented Jun 15, 2023 at 20:33
  • 1
    Same for php:8.2-apache. Switched to php:8.2-apache-bullseye.
    – visit1985
    Commented Jun 23, 2023 at 21:41
  • 1
    This answer saved my day today :D Thank you all! Commented Jul 4, 2023 at 17:29
12

If you wish to use Debian Bookworm, I got memcached working by installing libssl-dev also.

RUN apt install -y libmemcached-dev zlib1g-dev libssl-dev

Credit to AKorezin: https://github.com/php-memcached-dev/php-memcached/issues/541#issuecomment-1624041385

Then you can follow the usual PECL install process:

RUN yes '' | pecl install -f memcached-3.2.0 \
  && docker-php-ext-enable memcached
2
  • I got memcached working by installing libssl-dev as suggested in previous answer. Commented Oct 9, 2023 at 15:10
  • Yes, installing libssl-dev together with libmemcached-dev made pecl install of memcached work, though by which magic installing libssl would help Pecl memcached "find" libmemcached library during its build is beyond me. It's a very odd solution.
    – apotek
    Commented Mar 9 at 20:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .