如何使用 nodejs 扩展 docker php 图像?

rom*_*man 0 debian docker

我正在尝试使用 nodejs 扩展 docker 官方 php 图像。我遇到的问题是 apt 拒绝找到 wget、sudo、nodejs 之类的软件包,因此我无法安装它们。有谁知道解决办法吗?

Tim*_*lla 5

The official PHP image removes the APT lists after installing it's required packages, probably to keep the resulting image layers small. Therefore you need to apt-get update first:

RUN    apt-get update \
    && apt-get install -y wget nodejs --no-install-recommends \
    && rm -rf /var/lib/apt/lists/*
Run Code Online (Sandbox Code Playgroud)

The last command in the chain removes the lists created by apt-get update again.