When I run docker composer build
or docker compose build --no-cache
I get below error.
First I thought it was a network problem. But I tested the container does have internet access by placing a ping command in the docker file, which successfully receives a ping response.
What is the issue, and how can I solve it?
Step 6/16 : RUN apk add --upgrade --no-cache acl bash bash-doc bash-completion autoconf icu-dev libxml2-dev mysql-dev pcre php7-ctype php7-fileinfo php7-gd php7-intl php7-json php7-mbstring php7-openssl php7-simplexml php7-tokenizer php7-xml php7-bcmath php7-pdo php7-pdo_mysql freetype-dev libjpeg-turbo-dev libpng-dev nodejs patch tidyhtml-dev imap-dev libzip-dev git python2
---> Running in 1ae4ac5b75b6
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
ERROR: unable to select packages:
php7-bcmath (no such package):
required by: world[php7-bcmath]
php7-ctype (no such package):
required by: world[php7-ctype]
php7-fileinfo (no such package):
required by: world[php7-fileinfo]
php7-gd (no such package):
required by: world[php7-gd]
php7-intl (no such package):
required by: world[php7-intl]
php7-json (no such package):
required by: world[php7-json]
php7-mbstring (no such package):
required by: world[php7-mbstring]
php7-openssl (no such package):
required by: world[php7-openssl]
php7-pdo (no such package):
required by: world[php7-pdo]
php7-pdo_mysql (no such package):
required by: world[php7-pdo_mysql]
php7-simplexml (no such package):
required by: world[php7-simplexml]
php7-tokenizer (no such package):
required by: world[php7-tokenizer]
php7-xml (no such package):
required by: world[php7-xml]
python2 (no such package):
required by: world[python2]
ERROR: Service 'application' failed to build: The command '/bin/sh -c apk add --upgrade --no-cache acl bash bash-doc bash-completion autoconf icu-dev libxml2-dev mysql-dev pcre php7-ctype php7-fileinfo php7-gd php7-intl php7-json php7-mbstring php7-openssl php7-simplexml php7-tokenizer php7-xml php7-bcmath php7-pdo php7-pdo_mysql freetype-dev libjpeg-turbo-dev libpng-dev nodejs patch tidyhtml-dev imap-dev libzip-dev git python2' returned a non-zero code: 14
EDIT:
Tried suggestion of @Mureinik to use FROM php:7.4-fpm-alpine3.15
instead of FROM php:7.4-fpm-alpine
. When I tied this, it gets past the initial error. But I get a different error instead. See below.
#0 69.23 creating libtool
#0 69.26 appending configuration tag "CXX" to libtool
#0 69.32 configure: patching config.h.in
#0 69.32 configure: creating ./config.status
#0 69.36 config.status: creating config.h
#0 69.39 /bin/sh /usr/src/php/ext/iconv/libtool --mode=compile cc -I"/usr/include" -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/usr/src/php/ext/iconv -DPHP_ATOM_INC -I/usr/src/php/ext/iconv/include -I/usr/src/php/ext/iconv/main -I/usr/src/php/ext/iconv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -I/usr/include -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c /usr/src/php/ext/iconv/iconv.c -o iconv.lo
#0 69.45 mkdir .libs
#0 69.45 cc -I/usr/include -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/usr/src/php/ext/iconv -DPHP_ATOM_INC -I/usr/src/php/ext/iconv/include -I/usr/src/php/ext/iconv/main -I/usr/src/php/ext/iconv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -I/usr/include -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c /usr/src/php/ext/iconv/iconv.c -fPIC -DPIC -o .libs/iconv.o
#0 69.60 /usr/src/php/ext/iconv/iconv.c: In function 'zm_startup_miconv':
#0 69.60 /usr/src/php/ext/iconv/iconv.c:284:4: error: '_libiconv_version' undeclared (first use in this function)
#0 69.60 284 | _libiconv_version >> 8, _libiconv_version & 0xff);
#0 69.60 | ^~~~~~~~~~~~~~~~~
#0 69.60 /usr/src/php/ext/iconv/iconv.c:284:4: note: each undeclared identifier is reported only once for each function it appears in
#0 69.60 /usr/src/php/ext/iconv/iconv.c: In function '_php_iconv_appendl':
#0 69.60 /usr/src/php/ext/iconv/iconv.c:181:15: warning: implicit declaration of function 'libiconv'; did you mean 'iconv'? [-Wimplicit-function-declaration]
#0 69.60 181 | #define iconv libiconv
#0 69.60 | ^~~~~~~~
#0 69.60 /usr/src/php/ext/iconv/iconv.c:453:8: note: in expansion of macro 'iconv'
#0 69.60 453 | if (iconv(cd, (char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) {
#0 69.60 | ^~~~~
#0 69.64 make: *** [Makefile:192: iconv.lo] Error 1
------
failed to solve: executor failed running [/bin/sh -c docker-php-ext-install intl zip pcntl pdo_mysql iconv opcache soap tidy imap bcmath && php -r 'ini_set("display_errors", 1); error_reporting(-1); iconv("UTF-8", "ASCII//TRANSLIT", "foobar");']: exit code: 2
2
Answers
I looked at the
php7-bcmath
package, but it seems the same issue occurs in most of them.This package has builds for Alpine 3.13 through 3.15, but the latest Alpine is 3.16, which doesn’t have a build for this package yet. You can wait until it’s available, or lock down your Dockerfile to a specific Alpine version that has a build for this package, e.g.:
EDIT:
According to additional information supplied in the comments, the dockerfile uses
FROM php:7.4-fpm-alpine
, which internally usesFROM alpine
. Instead, you could use a version that locks down to a specific Alpine version:you might be missing some repositories under
/etc/apk/repositories
, which contains these packages. you will need to add them before you could download them.