Error on PHP 8.4-fpm IMAP package install with Dockerfile

In my Dockerfile for php8.4-fpm i am installing IMAP package with the following commands:

FROM php:8.4-fpm
[...]
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && 
    docker-php-ext-install imap

But got an error:

process "/bin/sh -c docker-php-ext-configure imap --with-kerberos --with-imap-ssl" did not complete successfully: exit code: 1

How to solve it?