Docker:您的系统中缺少请求的 PHP 扩展 bcmath

Ank*_*hah 0 bcmath docker

安装 bcmath 时出现以下错误

root@cfe90ea33de0:/var/www/web# apt install php-bcmath
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package php-bcmath is a virtual package provided by:
  php7.3-bcmath 7.3.14-1~deb10u1 [Not candidate version]
  php7.3-bcmath 7.3.11-1~deb10u1 [Not candidate version]
  php7.0-bcmath 7.0.33-0+deb9u7 [Not candidate version]
  php7.0-bcmath 7.0.33-0+deb9u6 [Not candidate version]

E: Package 'php-bcmath' has no installation candidate
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下命令仍然相同的错误

apt-get install php7.3-bcmath
apt-get install php7.0-bcmath
V=`php -v | sed -e '/^PHP/!d' -e 's/.* \([0-9]\+\.[0-9]\+\).*$/\1/'` \apt-get install php$V-bcmath
Run Code Online (Sandbox Code Playgroud)

Ank*_*hah 14

docker-php-ext-install bcmath
Run Code Online (Sandbox Code Playgroud)

登录到 Docker 后,上述命令有效。


小智 7

RUN docker-php-ext-install bcmath
Run Code Online (Sandbox Code Playgroud)

将其添加到您的 Docker 文件中并重建 docker 映像。