WordPress on IBM Containers Update

Share: Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditEmail this to someonePrint this page

Update – March 31, 2016: Thanks to a commenter, we noticed that we were mounting the volume below at the wrong path (/wp-content rather than /var/www/html). This means that WordPress updates, installations, and user uploads would be lost in the event of a container shutdown.

Unfortunately, after mapping the volume to the proper path, we found that the WordPress entrypoint script errors while trying to change the ownership of the WordPress files within the mounted volume. These errors are related to a limitation with the platform’s use of NFS and, until this issue can be resolved, users must override the official WordPress entrypoint script.

To provide an example, we have updated the ibmjstart/bluemix-wordpress image using this approach. To run the image on the IBM Bluemix Container service, simply perform the following steps from the cf ic command line plugin (optionally replacing the parameters with your own preferred names):

Back in May 2015, Miguel showed us all how to deploy WordPress on Bluemix using containers. Now you can use the official WordPress image from the Docker Hub instead of the custom image used in the previous tutorial!


This tutorial assumes you have already installed docker, the cf cli, and the cf “ic” plugin. For instructions on how to install these, please refer to the bluemix docs.

Step 0: Log into Bluemix and target your desired space

Step 1: Copy the official WordPress image to your IBM Containers Registry

As described in the Bluemix docs, “cpi” will automatically “Access a Docker Hub image or an image from your local registry and copy it to your private Bluemix repository.”

Step 2: Create the volume that will serve as the WordPress file system

You can name the volume whatever you want but remember the name for when you run the container in step 4.

Step 3: Create Services

For this tutorial we are going to use the “ClearDB MySQL Database” service which can be instantiated directly from the cf cli via

Optionally, if you would like to configure email notification for your site, you may wish to create an instance of the “SendGrid” service:

Refer to the Bluemix catalog for a comprehensive list of services and plan options.

Step 4: Run the Container with the WordPress Image

IBM Bluemix offers a consistent development model across its 3 compute options (cloud foundry, containers, and virtual machines) by allowing users to bind services to their application, container, or virtual machine.

The credentials for interacting with the service are injected into your application/container/VM via a special environment variable named VCAP_SERVICES.

In the case of containers, the service will also flatten the JSON structure of this environment variable as follows:

These are some example credentials as they would appear on the IBM Bluemix console.

This is how the same credentials would appear after being flattened.

To run the official WordPress image on IBM containers, we can map these VCAP_SERVICES environment variables to the ones expected by the image as part of our run command:

If you are working from a Windows machine you must run the command from the

Docker Quickstart Terminal.

Specifically, this command sets each WORDPRESS variable to the name of the corresponding VCAP_SERVICES variable, then passes a command which evaluates these assignments on the container before running the image’s normal entrypoint.

note:Make sure to replace [VOLUME], [NAMESPACE], [CLEARDB_SERVICE_INSTANCE], and [SENDGRID_SERVICE_INSTANCE] with their respective values.

Step 5: Requesting and Binding an IP

Check on the status of your new container:

Pay special attention to the PORTS column. We want it to contain your desired IP and port. If it is missing an IP, then you will need to request a new one (or unbind an existing one) and bind it.
To print your current list of IPs, run:

To request a new IP (free trial accounts are currently limited to 2):

To bind it to your container:

After binding the IP to the container you will access WordPress by typing the bound IP into your browser.

Setting up email in your WordPress Container (optional):

The wordpress image does not include an SMTP server and so the built-in WordPress email functionality will not work without an external service. If you have created and bound a SendGrid instance in the previous section, it is now just a matter of installing the corresponding plugin and setting the credentials.

Step 1. Install the SendGrid plugin in your WordPress instance.

The plugin can be installed in the wordpress ui (Plugins > AddNew > Search (Sendgrid))
Once it is installed, make sure to activate it.

Step 2. Set Credentials

Go to Plugins > Installed Plugins > SendGrid Settings

To fill out the username and password, you will need to print the credentials that were created when you bound this service instance to your container. To accomplish the binding and unbinding of service instances to a container, IBM Containers uses the Cloud Foundry Service Keys feature that was contributed in the summer of 2015.

While normally the credentials are injected into your running container, sometimes it is easier to just print the credentials and copy/paste them to the corresponding fields. To obtain the SendGrid username and password, you must first find the corresponding service key by running:

Once you find the service key associated with your running container (the container name should be in the key), you can retrieve the SendGrid credentials:

Fill in the Username and Password fields from the service key credentials and proceed to configure your own mail settings. You can try sending a test email from the same page. If the email is sent properly, then your WordPress installation is complete!

If you want to know more about the jStart team please visit our site, and talk to us more from our contact page.

Share: Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditEmail this to someonePrint this page
Luke Stack
Luke joined IBM's jStart team as a co-op in January 2016 . Luke is a junior, pursuing Bachelor’s of Science degrees in both Computer Science and Mathematics at Appalachian State University.
Luke Stack
Luke Stack

Latest posts by Luke Stack (see all)


  • Pingback: Wordpress on Bluemix Containers - IBM Emerging Technologies Blog

  • Baker

    Can you provide a workaround for in Step 4 for Windows users? Is it possible to add the VCAP_services env variables via the UI?

  • We have recently updated the article to address this issue. The current run command in step 4 should now also work on Windows as long as you run it from the Docker Quickstart Terminal.

  • Farhan

    I followed your article and the mapped the IBM container volume to /wp-content in cf ic run … command as mentioned in the above command. However, the wordpress container is using /var/www/htmal/wp-content folder for the contents.

    I tried to map the container volume to /var/www/html/wp-content but then the container failed to start wordpress. Looking at the container logs it turned out that wordpress is trying to change the ownership of the /var/www/html/wp-content folder which is mapped to container volume and getting failed.

    Please advise how can I change or map the /var/www/html/wp-content folder to container’r volume

  • Farhan, thank you for pointing out this oversight. We meant to keep the volume mounted at the same path as the original post (/var/www/html), but it looks like this is no longer working with the latest WordPress image. I’ve added an update to the top of the post with some advice on how you can work around this limitation, but unfortunately I think it means that we’ll need to continue wrapping the official image with our own Dockerfile in order to run it on IBM Containers at this time.

  • Simeon Petkov

    The line

    cf ic run -p 80 -v myVolume:/var/www/html -e CCS_BIND_SRV=wp-cleardb registry.ng.bluemix.net/myNamespace/bluemix-wordpress

    results in

    docker: Error parsing reference: “myVolume:/var/www/html” is not a valid repository/tag.

  • Simeon, this is the error you would receive if you missed the ‘-v’ flag, causing it to interpret your volume as the image tag. Please double-check you have properly entered the command.


  • Simeon Petkov

    I copy & paste it as you see it above.

  • Søren Skov

    I’m getting the same error-message as above from the command as written in the article

    (cf ic run -p 80 -v myVolume:/var/www/html -e CCS_BIND_SRV=wp-cleardb registry.ng.bluemix.net/myNamespace/bluemix-wordpress)

    with appropriate names substituted and used on eu-gb.

    Currently I’m having a hard time getting any of the guides for using wordpress on bluemix to work.

  • Actually, we started seeing this error as well now. Looks like it is actually caused by a change to the cf cli that was introduced with version 6.17 — the cli now eats the “-v” option instead of passing it to the plugin: https://github.com/cloudfoundry/cli/issues/825

    To work around the issue, simply use --volume instead of -v. I’ve also gone ahead and updated the post at the top of the blog entry with this change.

  • Simeon Petkov


  • Simeon Petkov

    And how can I change php.ini contents with the container set-up?

    Asking because of: The uploaded file exceeds the upload_max_filesize directive in php.ini

    Not sure how to change the file contents in the image …

  • Dileep Sharma

    Successfully executed all the steps but when I try to open the IP address which is bound to the container it doesn’t open. Can you please help.

  • Could you please provide more information about the issue you are experiencing? Did you follow the instructions at the top of the page under “Update – March 31, 2016” and then the instructions under “Step 5: Requesting and Binding an IP?”

  • Dileep Sharma

    Hi Luke, thanks for your quick response. Yes, I’ve followed exact same steps except the SendGrid plugin activation. When I try to open the ClearDB Dashboard from Bluemix here is what I get:


    [{“code”:”Internal Server Error”,”message”:”class org.scribe.exceptions.OAuthException: Cannot extract an acces token. Response was: {\n \”error\”: \”invalid_grant\”,\n \”error_description\”: \”Invalid authorization code: bmmccp.eyJ0eXBlIjoiY29kZSIsInJlZ2lvbiI6ImlibTp5cDp1cy1zb3V0aCIsImNvZGUiOnsiY29kZSI6Ijlmd2hIOCIsImNvbnRyb2wiOnsiY2xpZW50X2lkIjoibWFya2V0cGxhY2UiLCJzY29wZXMiOlsib3BlbmlkIiwiY2xvdWRfY29udHJvbGxlci5yZWFkIl0sInJlZGlyZWN0X3VyaSI6Imh0dHBzOi8vYmx1ZW1peC5tYXJrZXRwbGFjZS5pYm1jbG91ZC5jb20vYXBpL2N1c3RvbS9jbG91ZGZvdW5kcnkvdjIvc3NvL3JldHVybiJ9fX0.HPbGGSibQhC1h3kGje3NnxbUpxXX6ZhARmLDkyalots6mrF5Ga5cPD2a9hsiFya846yr81IXa70OgIUJtqMkk-i2PZ6ilFAnOt_un9uEvusevuwf-01p-bqb942YqbkyNWkQJmoJUE24rNxfRbLgcGhu43oAs78ggCmoGDN9Yct3uAPSN8jfau-cp8MEhF33sB5cUMLL78v2lw5r2vS51hNewR8QjrD21-2ILmZHyz4_uJcoKSYWtiWB-4N2q_pI3fqbn27lgXq7km5NZVedZsAC_O8rUkK1oOYLX6ATLS1VSyq89bMUOafkCPk_p6w1hXUT1AXs4ey4PNcZku8iBA\”,\n \”statusCode\”: 400,\n \”operation\”: \”GET https://uaa.ng.bluemix.net/oauth/token?grant_type=authorization_code&code=bmmccp.eyJ0eXBlIjoiY29kZSIsInJlZ2lvbiI6ImlibTp5cDp1cy1zb3V0aCIsImNvZGUiOnsiY29kZSI6Ijlmd2hIOCIsImNvbnRyb2wiOnsiY2xpZW50X2lkIjoibWFya2V0cGxhY2UiLCJzY29wZXMiOlsib3BlbmlkIiwiY2xvdWRfY29udHJvbGxlci5yZWFkIl0sInJlZGlyZWN0X3VyaSI6Imh0dHBzOi8vYmx1ZW1peC5tYXJrZXRwbGFjZS5pYm1jbG91ZC5jb20vYXBpL2N1c3RvbS9jbG91ZGZvdW5kcnkvdjIvc3NvL3JldHVybiJ9fX0.HPbGGSibQhC1h3kGje3NnxbUpxXX6ZhARmLDkyalots6mrF5Ga5cPD2a9hsiFya846yr81IXa70OgIUJtqMkk-i2PZ6ilFAnOt_un9uEvusevuwf-01p-bqb942YqbkyNWkQJmoJUE24rNxfRbLgcGhu43oAs78ggCmoGDN9Yct3uAPSN8jfau-cp8MEhF33sB5cUMLL78v2lw5r2vS51hNewR8QjrD21-2ILmZHyz4_uJcoKSYWtiWB-4N2q_pI3fqbn27lgXq7km5NZVedZsAC_O8rUkK1oOYLX6ATLS1VSyq89bMUOafkCPk_p6w1hXUT1AXs4ey4PNcZku8iBA&redirect_uri=https%3A%2F%2Fbluemix.marketplace.ibmcloud.com%2Fapi%2Fcustom%2Fcloudfoundry%2Fv2%2Fsso%2Freturn\”\n}”}]

    Here is the command I executed on the Docker Terminal replacing respective parameters:



    Then I linked the IP address with this command:

    cf ic ip bind sharp_poincare

    Where sharp_poincare is the container ID which is correctly linked to IP and running fine.
    Public IP:

    When I try accessing the IP I get following message in Chrome:


    This site can’t be reached took too long to respond.
    Reloading the page
    Checking the connection
    Checking the proxy and the firewall

  • Dileep Sharma

    Also how can I associate my custom domain with it?

  • Dileep,

    In March we issued an update to this post. This is located at the very top of the page. Instead of running what you ran, you should have ran the following:
    cf ic cpi ibmjstart/bluemix-wordpress bluemix-wordpress
    cf ic volume create myVolume
    cf create-service cleardb spark wp-cleardb
    cf ic run -p 80 –volume myVolume:/var/www/html -e CCS_BIND_SRV=wp-cleardb registry.ng.bluemix.net/[NAMESPACE]/bluemix-wordpress
    If there is not anything important in your ClearDB instance, I would recommend deleting it and starting the process from scratch.

  • To associate your custom domain to the bound IP, you will need to go to your DNS provider and follow their instructions for creating an “A record.” Alternatively, you could look into running the container as a “container group” of one. This would allow you to bind your domain directly.

  • Dileep Sharma

    Wow!!!!!!!!!!!!!!! Thank you so much Luke 🙂

    It works now 🙂

  • Thanks! It works now! Only problem I see is customize option under appearance menu from the admin dashboard isn’t working.

  • Pingback: So.. we’re on bluemix – To the blogmobile…

Leave a Reply to Dileep Sharma Cancel reply