Use SOAP client in a Docker container
By Michael Wutzke, , updated
SOAP is a network protocol that enables data to be exchanged between systems and remote procedure calls to be carried out. SOAP is still relatively widespread in 2020, especially among banks and insurance companies, even if SOAP is gradually being replaced by other technologies.
The SOAP client is not installed for many preconfigured Docker containers. This also applies to PHP Docker containers. So if you are facing the challenge of supplying a Docker container with a PHP SOAP client, you can do this with the following solution:
Step 1: Create Dockerfile in “my-directory/Dockerfile”
FROM (NAMEOFIMAGE) RUN rm /etc/apt/preferences.d/no-debian-php && apt-get update && apt-get install -y libxml2-dev php-soap && docker-php-ext-install soap
You can leave out “rm /etc/apt/preferences.d/no-debian-php && ” only for Debian and Ubuntu Linux distributions. In the docker-compose.yml file you have to replace the “image” with the following “build” command.
Step 2: Load docker-compose.yml (before the change)
image: (NAMEOFIMAGE)
Step 3: Adjust docker-compose.yml (the image is loaded and adapted via the Dockerfile)
build: ./my-directory