Skip to content
Advertisement

PECL Package Installation Fail In Docker

When installing opencensus-alpha from PECL package manager in docker as part of dockerfile, an error is thrown /bin/sh: pecl: not found

Dockerfile

FROM nginx:1.17.4-alpine

RUN apk --no-cache add php7 php7-fpm php7-mysqli php7-pdo_mysql php7-json php7-openssl php7-curl 
    php7-zlib php7-xml php7-simplexml php7-phar php7-intl php7-dom php7-xmlreader php7-xmlwriter  php7-ctype php7-session 
    php7-mbstring php7-gd php-zip supervisor  libxml2-dev php7-tokenizer

RUN pecl install opencensus-alpha

Is there any easy way opencensus-alpha can be installed and enabled in a docker container

Advertisement

Answer

You’ll need the php7-pear package to get the pecl command, and you’ll need php-dev, gcc, musl-dev, and make packages for pecl and phpize be be able to build and install other packages correctly.

Add a new RUN line:

RUN apk --no-cache add php7-pear php7-dev gcc musl-dev make

or amend your existing RUN line:

RUN apk --no-cache add php7 php7-fpm php7-mysqli php7-pdo_mysql php7-json php7-openssl php7-curl 
    php7-zlib php7-xml php7-simplexml php7-phar php7-intl php7-dom php7-xmlreader php7-xmlwriter  php7-ctype php7-session 
    php7-mbstring php7-gd php-zip supervisor  libxml2-dev php7-tokenizer php7-pear php7-dev gcc musl-dev make
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement