Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't enable Memcached on php:7.4-fpm-alpine #1132

Closed
LucianoVandi opened this issue Mar 2, 2021 · 5 comments
Closed

Can't enable Memcached on php:7.4-fpm-alpine #1132

LucianoVandi opened this issue Mar 2, 2021 · 5 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@LucianoVandi
Copy link

Hello, i'm trying to add memcached support to php:7.4-fpm-alpine, below my Dockerfile.

FROM php:7.4-fpm-alpine

RUN apk update && apk add --no-cache --allow-untrusted \
    apache2 apache2-ssl apache2-proxy \
    memcached php7-pecl-memcached

ENTRYPOINT [ "httpd", "-DFOREGROUND"]

The container build without any error, but if from within the container I do php -mcan't see the memcached module loaded.

[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

I'm on Mac OS 10.11.6, Docker CE Version 18.06.1-ce-mac73 (26764).

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Mar 2, 2021
@wglambert
Copy link

There's a docs entry for installing extensions https://github.com/docker-library/docs/tree/master/php#how-to-install-more-php-extensions

$ docker build -t php:test - << EOF
FROM php:7.4-fpm-alpine
RUN apk add libmemcached-dev libmemcached autoconf pkgconfig g++ zlib-dev make && pecl install memcached && \ 
docker-php-ext-enable memcached && apk del make g++ autoconf pkgconfig 
EOF

Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM php:7.4-fpm-alpine
 ---> 597b78d02952
Step 2/2 : RUN apk add libmemcached-dev libmemcached autoconf pkgconfig g++ zlib-dev make && pecl install memcached && docker-php-ext-enable memcached && apk del make g++ autoconf pkgconfig
 ---> Using cache
 ---> 3408f876001f
Successfully built 3408f876001f
Successfully tagged php:test

$ docker run --rm php:test php -m | grep memcached
memcached

See also #575 (comment)

I'd recommend instead running memcached in a separate container

And any reason why you're opting to install Apache in the fpm variant instead of using the default apache variant?

@LucianoVandi
Copy link
Author

@wglambert this solved my issue, thanks! Basically I can't install extensions with apk add? I need to reproduce an environment with php-fpm and apache2 through mpm_event_module/proxy_pass, but the apache variant uses mod_php.

@tianon
Copy link
Member

tianon commented Mar 3, 2021 via email

@LucianoVandi
Copy link
Author

@tianon thanks for the explanation. What are the advantage of using CLI variant? I need fpm anyway...

@tianon
Copy link
Member

tianon commented Mar 3, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants