29

I have been unable to get soap to work with my php Docker setup.

I am using Docker CE for Windows Version 18.03.1-ce-win65 (17513). PHP version 7.2.3

I've tried running from inside the container apt-get install php-soap which results in Reading package lists... Done
Building dependency tree
Reading state information... Done
* Package php-soap is a virtual package provided by: * php7.0-soap 7.0.27-0+deb9u1 [Not candidate version]*

E: Package 'php-soap' has no installation candidate

Running docker-php-ext-install soap results in the error configure: error: libxml2 not found. Please check your libxml2 installation.

However when looking at php info I see the following: libxml2 Version => 2.9.4

SpaghettiCodee
  • 393
  • 1
  • 3
  • 5

4 Answers4

62

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.

Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
  • Thanks. Will that only work as part of the docker build though? I've already run that in the container and the phpinfo suggests it is already installed. – SpaghettiCodee May 01 '18 at 18:55
  • You should be able to log into the container and run the apt-get install. The install adds the -dev package which is different to the one used by the PHP exe itself. – Nigel Ren May 01 '18 at 18:56
  • 2
    Never tried running `docker-php-ext-install soap` in the container, so would be interested if that runs. – Nigel Ren May 01 '18 at 18:57
  • 1
    For alpine-based containers the first command should be: `apk update && apk add libxml2-dev` – Hamid Rouhani Aug 13 '22 at 14:39
27

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.

The Vojtisek
  • 1,282
  • 17
  • 21
  • I get the error `ERROR: Module soap does not exist!` when trying this with `FROM php:7.3-apache-stretch` – Novocaine Aug 28 '19 at 13:10
5

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 ...
hizmarck
  • 686
  • 9
  • 19
-1

This is outside the scope of this repo.

You should get it via this approach:

RUN apt-get update -y \
  && apt-get install -y \
     libxml2-dev \
     php-soap \
  && apt-get clean -y \
  && docker-php-ext-install soap    
Moe Far
  • 2,742
  • 2
  • 23
  • 41