This applies to official WordPress image but can be used with PHP image also.
Create Dockerfile with following contents:
FROM wordpress:latest # Install gd and freetype RUN apt-get -y update \ && apt-get -y install php5-gd freetype* \ && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ && docker-php-ext-install -j$(nproc) gd
Build your image
docker build -t wordpress .
Or you can use my image here.