PHP Dockerfile with php-memcached not working

I can’t build any image with PHP-Memcached extension. All they give me an error messages and how many times I try it’s not helpful. I can’t even find any PHP Dockerfile which include memcached and it’s work. Even the main page of PHP docker page have Dockerfile with PHP Memcached solution and it’s also not working.

FROM php:5.6-cli

RUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev 

&& pecl install memcached-2.2.0 

&& docker-php-ext-enable memcached

Here is my last try code

FROM php:7.4-fpm

ADD php.ini /usr/local/etc/php/conf.d/php.ini

RUN docker-php-ext-install pdo pdo_mysql

# for mysqli if you want
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli

RUN printf "deb jessie mainndeb-src jessie mainndeb jessie/updates mainndeb-src jessie/updates main" > /etc/apt/sources.list

RUN apt-get update
RUN apt-get install -y libz-dev libmemcached-dev && 
    pecl install memcached && 
    docker-php-ext-enable memcached

Who knows about this something? Thanks, advice


Looks like I found the solution on my problem at last and it’s connected with /etc/apt/source.list

deb buster main
deb buster-updates main

And then just add this COPY ./sources.list /etc/apt/sourcee.list line in your Dockerfile and it will work

FROM php:7.2-fpm

COPY ./sources.list /etc/apt/sourcee.list