Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable EXIF support when running Wordpress Docker container

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

like image 907
quis Avatar asked Apr 18 '26 11:04

quis


1 Answers

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.

like image 140
quis Avatar answered Apr 20 '26 23:04

quis