Php: Missing dependency for bz2 ext

Created on 17 Nov 2014  路  7Comments  路  Source: docker-library/php

Installation of bz2 extension in inherited dockerfile throws error

RUN docker-php-ext-install bz2
configure: error: Please reinstall the BZip2 distribution

In order to fix it the following dependency needs to be installed

RUN apt-get update && apt-get install -y libbz2-dev

Most helpful comment

So why not just do the following?

FROM php
RUN apt-get update && apt-get install -y libbz2-dev
RUN docker-php-ext-install bz2

All 7 comments

So why not just do the following?

FROM php
RUN apt-get update && apt-get install -y libbz2-dev
RUN docker-php-ext-install bz2

Why bzip2 is installed as dependency in Dockerfile?

The reason for not installing libbz2-dev is that the php module is not installed but left to the user to add the dependencies and install the module when they require it.

If it is a common enough module then we would look to add it always (like curl, openssl, and zlib). Does the general community think the bz2 module should always be available and loaded?

@denisura: Although the bzip2 package is installed temporarily as a build dependency in order to extract php.tar.bz2, it is removed in the same RUN command and is no longer installed in the final image.

Instruction to install all required dependencies before running docker-php-ext-install some-ext might be helpful ;-)

RUN apt-get update && apt-get install -y libbz2-dev
RUN docker-php-ext-install bz2

Works for me

Put that somewhere or below the last installed extension in your Workspace Dockerfile:

###########################################################################
# BZ2:
###########################################################################

USER root

ARG INSTALL_BZ2=false

RUN if [ ${INSTALL_BZ2} = true ]; then \
    apt-get update && \
    apt-get install -y libbz2-dev && \
    apt-get install -y php${LARADOCK_PHP_VERSION}-bz2 \
;fi

Don't forget to add the env var in your .env and map it in your .yml (or remove the if...)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sanjay-rakholiya picture sanjay-rakholiya  路  3Comments

ktrzos picture ktrzos  路  3Comments

ihorsamusenko picture ihorsamusenko  路  4Comments

pukkancs picture pukkancs  路  3Comments

ambroisemaupate picture ambroisemaupate  路  3Comments