我正在考虑在fpm高山集装箱上设置laravel。遇到一个障碍,下面的Dockerfile正在产生一些错误。。。
FROM php:7-fpm-alpine
# install extensions needed for Laravel
RUN apk --update add
php7-mysqli
php7-mcrypt
php7-mbstring
rm /var/cache/apk/*
产生的错误有:
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
我可以搜索这些包名称,并在alpinelinux网站上找到它们。我有什么想法可以解决这个问题吗?就好像它没有更新apt缓存。。。但是添加一个LS,我可以在那里看到内容:
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
我能做些什么来解决这个问题吗?
Base Docker映像可能引用了不正确的存储库。
将正确的存储库传递给apk add
命令,如下所示:
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
我没有使用docker-php-ext-install
,这是在容器中添加工作时所必需的。。。
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/*
我遇到了同样的错误。通过从其名称中删除包版本来解决问题:
https://github.com/docker-library/php/issues/225#issuecomment-220339154
我遇到了同样的错误,并在这里尝试了解决方案,发现apk update
至关重要。