I'm looking at setting up laravel on an fpm-alpine container. Running into a snag where the below Dockerfile is producing some errors...
FROM php:7-fpm-alpine
# install extensions needed for Laravel
RUN apk --update add \
php7-mysqli \
php7-mcrypt \
php7-mbstring \
rm /var/cache/apk/*
Errors produced are:
Building fpm
Step 1 : FROM php:7-fpm-alpine
---> 9e6811cb8bac
Step 2 : RUN apk --update add php7-mysqli php7-mcrypt php7-mbstring rm /var/cache/apk/*
---> Running in 87364957eb57
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
/var/cache/apk/* (missing):
required by: world[/var/cache/apk/*]
php7-mbstring (missing):
required by: world[php7-mbstring]
php7-mcrypt (missing):
required by: world[php7-mcrypt]
php7-mysqli (missing):
required by: world[php7-mysqli]
rm (missing):
required by: world[rm]
ERROR: Service 'fpm' failed to build: The command '/bin/sh -c apk --update add php7-mysqli php7-mcrypt php7-mbstring rm /var/cache/apk/*' returned a non-zero code: 5
I can search for these package names and find them on the alpine linux web site. Any thoughts on how I can work around this? It's like it's not updating the apt cache... but adding an LS I can see contents there:
Building fpm
Step 1 : FROM php:7-fpm-alpine
---> 9e6811cb8bac
Step 2 : RUN apk update
---> Using cache
---> 9ef09f3aa2a2
Step 3 : RUN ls /var/cache/apk
---> Running in e126a083a306
APKINDEX.5a59b88b.tar.gz
APKINDEX.7c1f02d6.tar.gz
Any ideas on what I can do to resolve this?
Base Docker image probably references an incorrect repository.
Pass over the correct repositories to the apk add
command like this:
RUN apk add --update \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
php7-mysqli php7-mcrypt php7-mbstring
I wasn't using docker-php-ext-install
which is required when adding working within the container...
FROM php:7-fpm-alpine
# install extensions needed for Laravel
RUN apk update \
&& apk add libmcrypt-dev \
&& docker-php-ext-install mcrypt mysqli pdo_mysql \
&& rm /var/cache/apk/*
I met the same error. Solved it by removing the package version from its name:
https://github.com/docker-library/php/issues/225#issuecomment-220339154
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With