首页 > 解决方案 > Docker PHP Addons E: 包 'php-json' 没有安装候选

问题描述

今天我尝试为默认的 php docker 容器安装一些 PHP 扩展。我的 dockerfile 看起来像这样:

FROM php:7.2-cli
#remove apt install restriction
RUN rm /etc/apt/preferences.d/no-debian-php

#Install php-addons
RUN apt-get update \
&& apt-get install -y php-zip php-xml php-json php-mbstring

COPY . /
WORKDIR /

默认情况下我有2个错误。

错误:1 http://deb.debian.org/debian stretch InRelease 解决“deb.debian.org”临时失败无法解析“archive.ubuntu.com”

E: 包 'php-json' 没有安装候选

标签: phpdocker

解决方案


解决方案是:

E: 包 'php-json' 没有安装候选

用 dockerfile 中的这一行修复

RUN rm /etc/apt/preferences.d/no-debian-php

错误:1 http://deb.debian.org/debian stretch InRelease 解决“deb.debian.org”临时失败无法解析“archive.ubuntu.com”

固定与

Uncomment the following line in /etc/default/docker
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"

推荐阅读