问题
This is my Dockerfile
FROM php:7.1-fpm-alpine
RUN docker-php-ext-install mysqli
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repositories &&
apk update && \
apk upgrade && \
apk add --update \
php7-gd
mysqli is ok, but it does not load GD library.
I also find gd.so in alpine container, please check the image:
Please help
回答1:
You should not mix Alpine Linux 3.4, Alpine Linux edge and PHP compiled from source.
Solution 1
Use the official latest release of Alpine Linux
FROM alpine:3.5
and add
http://dl-cdn.alpinelinux.org/alpine/3.5/community
then install memcache using pecl (in php7-pear).
Solution 2
Use the docker-php-ext-install script to add gd
FROM php:7.1-fpm-alpine
RUN apk add --no-cache libpng libpng-dev && docker-php-ext-install gd && apk del libpng-dev
For more image support you can also apk add and del:
libjpeg-turbo-dev libwebp-dev zlib-dev libxpm-dev
I left the answer using the official Alpine Linux on top, since we should always try to use official docker repos. But currently the second solution is better.
The second solution was provided by ncopa at the Alpine Linux IRC channel. Thanks.
来源:https://stackoverflow.com/questions/42087734/install-php7-gd-in-alpine