Enable soap for php in docker container

The correct answer was done, but for me, I needed also to enable (docker-php-ext-enable soap) the soap module, so for If someone could be useful:

FROM php:7.4.24-apache

# your configurations ...

RUN apt-get update && \
    apt-get install -y libxml2-dev
RUN docker-php-ext-install soap && docker-php-ext-enable soap

# other configurations ...

You will need to install libxml2-dev as part of your dockerfile, the image is kept to a minimum and doesn't include all of the bits needed by every module. Although the image may have the main package, the -dev package includes the components needed to compile other modules which rely on it...

RUN apt-get update && \
    apt-get install -y libxml2-dev

(From https://github.com/docker-library/php/issues/315)

Just to make it clear - the command

RUN docker-php-ext-install soap

will then run successfully to install the soap library.


For me, working with PHP 7.3.2, the other solutions didn't work.

Both "php-soap" and "php7.3-soap" got "phpXXX-soap has no installation candidate" error.

Alone "docker-php-ext-install soap" wanted the "libxml2-dev" so i just installed the necessities:

FROM php:7.3
RUN apt-get update -y \
  && apt-get install -y \
     libxml2-dev \
  && apt-get clean -y \
  && docker-php-ext-install soap  

... and it worked nicely.

Tags:

Docker

Php

Soap