Deploying WordPress

This tutorial demonstrates how to deploy the official WordPress Docker image to the Apcera Platform using a multi-resource manifest.


To complete this tutorial you will need a MySQL provider and an APCFS provider. To verify that you have these providers in your cluster run apc providers list -ns / and look for providers of type nfs and mysql.

apc provider list -ns /
Working in "/"
│ Name     │ Type     │ Namespace         │ Description             │
│ apcfs    │ nfs      │ /apcera/providers │ NFSv4                   │
│ mysql    │ mysql    │ /apcera/providers │ MySQL                   │

If you don't have a MySQL provider you can create one.

You will also need policy permissions to deploy Docker jobs (see Policy requirements for Docker). The following policy lets you pull any image from any Docker registry.

on job::/ {
    { docker.allow "*"}

Deploy WordPress using manifest

The following multi-resource manifest creates deploys Wordpress from its official image on Docker Hub. It also creates a MySQL service and APCFS service (from their corresponding providers) and binds those services to the Wordpress application. The env section uses runtime templates to define the necessary environment variables for Wordpress that provide the location and name of the MySQL database and credentials to access the database. An auto-generated route endpoint is created and mapped to port 80, where Wordpress listens for connections.

    "jobs": {
        "job::/sandbox/admin::myblog": {
            "docker": {
                "image": "library/wordpress:latest"
            "exposed_ports": [ 80],
            "routes": [
                    "type": "http",
                    "endpoint": "auto",
                    "config": {
                        "/": [ { "weight":100, "port":80 } ]
                "egress": {
                    "fqn": "service::/apcera::outside"
                "mysql-wordpress": {
                    "fqn": "service::/sandbox/admin::myblog-mysql"
                "var-www-html": {
                    "fqn": "service::/sandbox/admin::wordpress-www-html",
                    "params": {
                        "mountpath": "/var/www/html"
            "env": {
                "{{ (binding_service \"myblog-mysql\").URI.Host }}:{{ (binding_service \"myblog-mysql\").URI.Port }}",
                "{{ (binding_service \"myblog-mysql\").URI.User }}",
                "{{ (binding_service \"myblog-mysql\").URI.Password }}",
                "{{ (binding_service \"myblog-mysql\").URI.TrimmedPath }}"
            "state": "started"
    "services": {
        "service::/sandbox/admin::myblog-mysql": {
            "description": "Database for myblog wordpress",
            "name": "myblog-mysql",
            "provider_fqn": "provider::/apcera/providers::mysql-provider",
            "type": "mysql"
        "service::/sandbox/admin::wordpress-www-html": {
            "description": "NFS storage for blog files",
            "name": "wordpress-www-html",
            "provider_fqn": "provider::/apcera/providers::apcfs",
            "type": "nfs"

To deploy the Wordpress using a manifest:

  1. Copy the contents of the above manifest to a file named wordpress-manifest.json.
  2. Run the following command:
    apc manifest deploy wordpress-manifest.json
  3. When the deploy is complete run the following command to show information about the newly created application. Locate the Route field and open the app's assigned route in a web browser. (Note that it may take up to 2 minutes for WordPress to copy the necessary files and be ready to access. )
    apc app show /sandbox/admin::myblog
    │ Job:               │ myblog                                                            │
    │ FQN:               │ job::/sandbox/admin::myblog                                 │
    │ UUID:              │ b5f3ef87-c7dd-4ab8-9301-d6f3751234e3                              │
    │ ......             │                                                                   │
    │                    │                                                                   │
    │ Routes:            │ [to port 80] (Weight: 100.00)    │

Deploy WordPress using APC

The following APC command uses runtime variables to parse the required DB parameters and deploy a WordPress Docker job.

To deploy Wordpress using APC:

  1. Run the following command, changing <mycluster> in the --routes URL to match your cluster's subdomain:
    apc docker run myword -i wordpress \ 
    --env-set 'WORDPRESS_DB_HOST={{ (binding_service "myword-mysql").URI.Host }}:{{ (binding_service "myword-mysql").URI.Port }}' \
    --env-set 'WORDPRESS_DB_USER={{ (binding_service "myword-mysql").URI.User }}' \
    --env-set 'WORDPRESS_DB_PASSWORD={{ (binding_service "myword-mysql").URI.Password }}' \
    --env-set 'WORDPRESS_DB_NAME={{ (binding_service "myword-mysql").URI.TrimmedPath }}' \
    --routes http://myword.<mycluster> --port 80 \
    --provider /apcera/providers::apcfs --no-start

    Be sure to include the --no-start flag so that you do not start WordPress. You will this after binding the job to MySQL.

  2. Create the MySQL service.
    apc service create myword-mysql --provider /apcera/providers::mysql
  3. Bind the WordPress job to the MySQL service.
    apc service bind myword-mysql -j myword
  4. Start the WordPress job.
    apc job start myword

    The WordPress "Welcome" page should be accessible at the --routes URL, such as

Create MySQL provider

If you don't have a MySQL provider, or if you want to create one in your namespace, you can deploy the official MySQL Docker image as a job backed by NFS for persistence.

To do this, run the following APC commands:

  • Create a MySQL instance:
    apc docker run mysql --restart always --image mysql \
    --tag 5.7.11 --port 3306 --provider /apcera/providers::apcfs \
    --env-set MYSQL_ROOT_PASSWORD=password
  • Register a MySQL provider on the instance:
    apc provider register mysql-provider --job mysql \
    -u mysql://root:password@mysql-server

To verify that you successfully created the provider, in the web console go to the Providers screen, or use the APC command apc providers list -ns /.