Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable soap for php in docker container

Tags:

php

soap

docker

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

like image 609
SpaghettiCodee Avatar asked May 01 '18 18:05

SpaghettiCodee


Video Answer


2 Answers

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.

like image 191
Nigel Ren Avatar answered Sep 18 '22 11:09

Nigel Ren


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.

like image 20
The Vojtisek Avatar answered Sep 22 '22 11:09

The Vojtisek