docker php7.2-fpm can't install imap module
Asked Answered
N

4

11

I'm having problems trying to get imap working with my docker-compose.

Here is what my php dockerfile looks like.

FROM php:7.2-fpm

RUN apt-get update && \
  apt-get install -y \
    curl \
    libmcrypt-dev \
    unzip \
    git 

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install- 
dir=/usr/local/bin --filename=composer
RUN composer --version

# Set timezone to UTC
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/UTC /etc/localtime
RUN "date"

RUN apt-get -y install libmagickwand-dev --no-install-recommends \
    && pecl install imagick \
    && docker-php-ext-enable imagick \
    && rm -r /var/lib/apt/lists/*

RUN /usr/local/bin/docker-php-ext-install pdo pdo_mysql

ADD ./scripts/entry.sh /root/init.sh

WORKDIR /var/www/insight

But I keep getting the error

Call to undefined function imap_open()

I've been trying a lot of different ways of getting the imap to work, but nothing seems to be working for me. I need to keep using php7.2 so downgrading to php5 is not an option for me.

My ideal outcome is to keep the current php version of fpm and find a nice solution to get imap working with the current dockerfile.

Adding

Docker-php-ext-install imap 

inside the dockerfile does not seem to work and result with the following error:

configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
Nobie answered 16/4, 2018 at 10:12 Comment(6)
Try adding imap-dev to your apt-get install ... (from github.com/docker-library/php/issues/244)Herrin
@NigelRen result in : E: Unable to locate package imap-devNobie
As an alternative, try libc-client-devel (from #13436856)Herrin
@NigelRen also unable to locate that package, since my image is based on ubuntu I tried package libc-client2007e-dev, for the sake of it I also tried to use libc-client-dev and libc-client-devel but all result in the unable to locate package.Nobie
libc-client2007e-dev exists in Ubuntu, try logging into your container and see if you can do this step manually.Herrin
@NigelRen sadly even inside the container I am unable to run apt-get install libc-client2007e-dev. Still the same error, unable to find the package.Nobie
D
13

To use imap module with PHP in Docker you must configure extension like this

docker-php-ext-configure imap --with-kerberos --with-imap-ssl

You can see an example of Dockerfile in one of my project

Dextroglucose answered 16/4, 2018 at 13:19 Comment(2)
I just found this out aswell, but since it's the same solution and I confirmed that yours worked aswell I'll go and accept it, cheers!Nobie
I had to run this apt-get install -y libc-client-dev libkrb5-dev && rm -r /var/lib/apt/lists/* && docker-php-ext-configure imap --with-kerberos --with-imap-ssl && docker-php-ext-install imap Crackerjack
M
9

Actual on 2020 for PHP 7.4 and PHP 8 on Linux Alpine

RUN apk add imap-dev krb5-dev
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
        && docker-php-ext-install imap \
        && docker-php-ext-enable imap
Mola answered 24/11, 2020 at 9:37 Comment(0)
B
4

Solved it by using

RUN apt update && apt install -y libc-client-dev libkrb5-dev && rm -r /var/lib/apt/

RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && docker-php-ext-install imap

Found at https://mcmap.net/q/1014175/-errors-when-installing-imap-extension-on-official-php-docker-image-duplicate

Bruin answered 3/12, 2020 at 11:13 Comment(0)
U
0

Try this

# Enable php-imap
RUN apt-get update && \
    apt-get install -y \
        libc-client-dev libkrb5-dev && \
    rm -r /var/lib/apt/lists/*
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
    docker-php-ext-install -j$(nproc) imap
Unused answered 25/8, 2023 at 15:58 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.