Docker install memcached

user7593291 picture user7593291 · Feb 20, 2017 · Viewed 8.7k times · Source

I am trying to install memcached in Dockerfile but I keep getting th same error. Everything was working fine but looks like some layers were cached I and the images was being built with no problems at all. But since I cleared the cache I can't build the image. Here is some of it's content:

FROM php:5-apache

RUN apt-get install -y libmemcached11 libmemcachedutil2 build-essential libmemcached-dev libz-dev
RUN pecl install memcached
RUN echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini

There are many other things that are installed but as I said everything was working before. The error is that memcached requires php7 to run. I dont know if something has changed in the recent builds of the library but looks like it refuses to work with php5. Here is the error:

pecl/memcached requires PHP (version >= 7.0.0), installed version is 5.6.30
pecl/memcached can optionally use PHP extension "igbinary" (version >= 2.0)
pecl/memcached can optionally use PHP extension "msgpack" (version >= 2.0)
No valid packages found
install failed
The command '/bin/sh -c pecl install memcached' returned a non-zero code: 1

Answer

fzgregor picture fzgregor · Feb 20, 2017

The PECL memcached package introduced the dependency on PHP 7 in version 3.0.0. You can still install the 2.x version of that package:

FROM php:5-apache

RUN apt-get update && apt-get install -y libmemcached11 libmemcachedutil2 build-essential libmemcached-dev libz-dev
RUN pecl install memcached-2.2.0
RUN echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini