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 http://archive.debian.org/debian/ jessie mainndeb-src http://archive.debian.org/debian/ jessie mainndeb http://security.debian.org jessie/updates mainndeb-src http://security.debian.org 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
2
Answers
Looks like I found the solution on my problem at last and it's connected with /etc/apt/source.list
And then just add this
COPY ./sources.list /etc/apt/sourcee.list
line in your Dockerfile and it will workI have separated memcached and phm-memcached. The first one is a container, and second is installed on Dockerfile for PHP.
My docker-compose file :
And in my Dockerfile for PHP:
And with this, in my symfony application, i can store data in memcached.