2
votes

I have a PHP-CLI Docker image of Debian Buster and would like to install php-imagick package but with command:

Dockerfile:

RUN apt-get install -y php-imagick

I get an error:

Package php-imagick is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'php-imagick' has no installation candidate

running before:

RUN apt-get update -y && apt-get upgrade -y

did not help.

how come there is no package candidate for php-imagick?
how to install and enable imagick extension for this PHP Docker image?

Dockerfile to replicate issue:

FROM php:7.3-buster

RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y php-imagick

build command

docker build --tag testimage .
1

1 Answers

1
votes

Unless you have a good reason not to, using the packages from https://deb.sury.org/ is probably a good idea. The following appears to work:

FROM debian:buster-slim

USER root

# Get Debian up-to-date
RUN apt-get update -qq \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y git \
    mariadb-client wget curl \
    ca-certificates lsb-release apt-transport-https gnupg bsdmainutils

RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee -a /etc/apt/sources.list.d/php.list \
    && curl https://packages.sury.org/php/apt.gpg | apt-key add - \
    && apt-get update -qq \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y php7.3 php7.3-common php7.3-cli \
    php7.3-mysql php7.3-curl php7.3-xml php7.3-mbstring \
    php7.3-intl php7.3-redis php7.3-zip \
    php7.3-imagick supervisor