Enable soap for php in docker container

2022-08-30 17:23:17

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 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]*apt-get install php-soap

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

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

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


答案 1

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.


答案 2

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.


推荐