DEV Community

Raquel Campuzano Godoy
Raquel Campuzano Godoy

Posted on • Updated on

Develop Locally A Custom WordPress Using A Bitnami Docker Image

Originally published at

Why WordPress and Why Containers for Local Development?

When you are searching for an open-source CMS to create your blog or website, chances are that you finally chose WordPress.

WordPress is easy to use and includes a lot of plugins and themes enabled by default so you can run your website in a matter of minutes.

The best way to start developing locally is to use containers. They offer many of the same advantages as developing in VMs, but with lower overhead in terms of developer effort and development machine resources.

Bitnami containers are a great resource for local development: they allow you to save a lot of time in coding and ensure that you launch always the latest and secure application image.

As a developer, you may probably want to add some customizations to the default configuration that Bitnami delivers in its containers. This tutorial shows how to add and activate both a custom plugin and a theme for the first run.

Set Up Prerequisites

Before starting, make sure that you have already set up the following:

Step 1: Create a Script To Add a Plugin and a Theme

To begin the process, you need to obtain the Bitnami Docker image for WordPress.

1) Clone the Bitnami Docker WordPress repository and change to the directory that contains all files:

git clone
cd bitnami-docker-wordpress

The next step is to create a script to specify which are the plugins/themes you want to install in your WordPress. This script will contain the instructions to download and uncompress the plugin and the theme files as well as the path where they should be installed (/opt/bitnami/wordpress/wp-content/).

2) In the rootfs/ directory, create a file named with the following content:

curl -o /tmp/
curl -o /tmp/
unzip /tmp/ -d /opt/bitnami/wordpress/wp-content/plugins
unzip /tmp/ -d /opt/bitnami/wordpress/wp-content/themes

Step 2: Edit the Dockerfile To Add the Custom Script

To install the plugins and themes you have selected in the first run, it is necessary to indicate in the Dockerfile where are the instructions to perform that action.

1) Open the Dockerfile (5/debian-9/Dockerfile) and add the unzip packages to the RUN install_packages command list:

# Install required system packages and dependencies
RUN install_packages unzip libbz2-1.0 libc6 libcomerr2 libcurl3 libexpat1 libffi6 libfreetype6 libgcc1 libgcrypt20 libgmp10 libgnutls30 libgpg-error0 libgssapi-krb5-2 libhogweed4 libicu57 libidn11 libidn2-0 libjpeg62-turbo libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 libldap-2.4-2 liblzma5 libmemcached11 libmemcachedutil2 libncurses5 libnettle6 libnghttp2-14 libp11-kit0 libpcre3 libpng16-16 libpq5 libpsl5 libreadline7 librtmp1 libsasl2-2 libsqlite3-0 libssh2-1 libssl1.0.2 libssl1.1 libstdc++6 libsybdb5 libtasn1-6 libtidy5 libtinfo5 libunistring0 libxml2 libxslt1.1 libzip4 zlib1g

2) Add the RUN bash command under the COPY rootfs/ line:

COPY rootfs /
RUN bash

Step 3: Activate the Plugin and Theme at Initialization Time

To initialize the container with the installed plugin and theme already activated, it is necessary to add this action in the application entrypoint script.

1) Open the (5/debian-9/rootfs/ file and add the following:

nami_initialize apache php mysql-client wordpress
su daemon -s /bin/bash -c '/opt/bitnami/wp-cli/bin/wp plugin activate bbpress'
su daemon -s /bin/bash -c '/opt/bitnami/wp-cli/bin/wp theme activate gambit'
info "Starting wordpress... "

Step 4: Edit the docker-compose.yml File To Point To Your Image

By default, the docker-compose.yml file is pointing to the latest version of the WordPress Docker image packaged by Bitnami. To point to your custom image, it is necessary to change that value in the docker-compose.yml.

In the next steps, remember to replace "DOCKER_USERNAME/my-custom-wordpress" with the username of your Docker account and the name of your image, respectively.

   image: 'DOCKER_USERNAME/my-custom-wordpress:latest'

Step 5: Build the Docker Image

Let's build the Docker image.

1) Execute the docker build command within the directory that contains the Dockerfile (5/debian-9/):

cd 5/debian-9/
docker build -t DOCKER_USERNAME/my-custom-wordpress:latest .

2) Check that the image has been added to the local repository by executing:

docker images | grep my-custom-wordpress

Step 6: Test the Docker Image and Access Locally To Your Custom Application

To test locally your custom image, it is necessary to run the container.

1) Execute the docker-compose up command:

docker-compose up

If everything went well, you should see an output message similar to this:

Plugin Activated

2) Enter http://localhost in your web browser and check that the theme is already activated:

Theme Activated

3) Log in to the WordPress admin panel using the default credentials: username user and password bitnami.

Navigate to the "Plugins" section. You will see the BBplugin already installed and activated:

Plugin Enabled

Step 7: Publish the Docker Image

Now that your Docker image is built and contains your application code, you can upload it into a public registry. This guide uses Docker Hub, but you can select one of your own choice such as:

1) Log in to Docker Hub

docker login

2) Push the image to your Docker Hub account:

docker push DOCKER_USERNAME/my-custom-app:latest

Congratulations! You have customized a WordPress Docker image, tested and built it, and now it is available in Docker Hub and ready to be deployed in a production scenario!

Next Steps

Deploy a Custom WordPress Image on a Kubernetes Cluster Using Bitnami Helm Charts

Top comments (2)

franzcisco profile image
François Duroy

For those reading and struggling with this tuto as I did, here is my repo
Not sure if it's the right way to do it but it's working and it solved bugs encountered following this tutorial.
I managed with the help of answers found in the issues descriptions ( and with efforts trying, having errors, correcting, ...

franzcisco profile image
François Duroy

Hi Raquel,
Thanks for the article.
I have done exactly what you explained in the article but it seems I am having an issue connecting to the database..
Do you have any suggestion to help me fix this?
THanks you in advance.
Best regards