I'm trying to run a Wordpress site inside the official Wordpress Docker container .
The Wordpress site that I've built relies on using exif_read_data
to extract meta information from photos. I understand that PHP needs to be configured with the --with-exif
flag for this to work.
This is the Configure Command section of <?php phpinfo() ?>
's output when I'm running my site from the Docker container: './configure' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--disable-cgi' '--enable-ftp' '--enable-mbstring' '--enable-mysqlnd' '--with-curl' '--with-libedit' '--with-openssl' '--with-zlib' '--with-apxs2' 'CFLAGS=-fstack-protector-strong '-fpic' '-fpie' '-O2'' 'LDFLAGS=-Wl,-O1 '-Wl,--hash-style=both' '-pie'' 'CPPFLAGS=-fstack-protector-strong '-fpic' '-fpie' '-O2''
How can I reconfigure PHP to have EXIF support enabled? I'd like to keep using the official Wordpress Docker container because it seems to be working really well otherwise.
My docker-compose.yml
is here: https://github.com/quis/quis.cc/blob/d89efebefc20f688afbd70f8d7a58e35380581e9/docker-compose.yml
OK, I figured it out.
EXIF support can be enabled by running the docker-php-ext-install exif
command. This command only works when building the container.
I can't modify the official container; the Docker way to do this (which is the part I didn't understand) is to build my own container on top of the official one. Then when I build my own container I can run the command to enable EXIF support. Everything else is inherited from the official Wordpress container. So I made a file called Dockerfile
containing this:
FROM wordpress:latest
RUN docker-php-ext-install exif
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apache2-foreground"]
Then I ran this shell command to build an image from this file:
docker build -t wordpress-exif .
Then it's just a case of pointing the Docker compose file at my custom container, rather than the generic one. So in docker-compose.yml
I changed image: wordpress:latest
to image: wordpress-exif
.
I tried installing and enabling exif like other answers, but not luck.
Finally, it worked by adding the package.
RUN apk add --no-cache php7-exif
I used php:7.4-alpine
If you are using PHP 7.2+ the exif extension may already be installed but disabled. Add this line to Dockerfile to enable it:
RUN docker-php-ext-enable exif
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.