Adding PHP Extension on Docker at Azure VM

Adding PHP Extension on Docker at Azure VM

Last week I got problem with my Wodpress Plugin, it said

This plugin requires the PHP version >= 5.4.0 , and a following list of PHP extensions to be enabled: cURL, XMLWriter, OpenSSL, HASH, DOM

Then I go to my VM using putty, try to install those PHP Extension, before I run ‘apt-get install …..’, I tried to check the PHP version

[email protected]:/home/users# php -v

The program ‘php’ is currently not installed. You can install it by typing:

apt-get install php5-cli

I was shocked.. where’s my PHP, my wordpress application.. then I realized that I’m choose WordPress + mysql with Docker Engine

So I tried to find how to enable the php extension in docker container. And this tutorial based on my question in MSDN Forum ( and I write down this blog to make easier to find the solution when I need it again.

Below is the steps

The steps for entering Docker Container:
1. Remote the VM for Docker, command `ssh <username>@<vm-host>`
2. Get the container name of the `wordpress` container, command `docker ps` and find the NAME for the image `wordpress`

3. Get the PID of the `wordpress` container, command `docker inspect -f “{{.State.Pid}}” <container-name>`

4. Enter into the `wordpress` container, command `sudo nsenter –target <PID> –mount –uts –ipc –net –pid`

5. run ‘apt-get install php-curl’ etc

Leave a Reply

Your email address will not be published. Required fields are marked *

Optimization WordPress Plugins & Solutions by W3 EDGE