How to run WordPress with docker on Linux/macOS/Windows 10?

In this tutorial, I will show to what to do in order to set up a WordPress container with its own database on Linux/macOS/Windows 10. You’ll be guided step by step, we will configure a network, make some containers and learn some basics for docker.

How to create a docker network and why?

We need a separate network to connect our containers and isolate them. What containers? WordPress and a database, MariaDB.

docker network create wordpress-stack

How to create a persistent database?

We need to make a volume for our database because we want it to persist every time the container is stopped or started.

docker volume create --name mariadb_data

Let’s create the MariaDB container with its volume:

docker run -d --name mariadb -e ALLOW_EMPTY_PASSWORD=yes -e MARIADB_USER=bn_wordpress -e MARIADB_DATABASE=bitnami_wordpress --net wordpress-stack --volume mariadb_data:/bitnami bitnami/mariadb:latest

As you can observe, it is attached to wordpress-stack network.

The database is now up and running, we’ll configure the WordPress container too.

How to create and connect the WordPress container?

docker volume create --name wordpress_data

And now configure the container:

docker run --name wordpress -p 80:80 -e ALLOW_EMPTY_PASSWORD=yes -e WORDPRESS_DATABASE_USER=bn_wordpress -e WORDPRESS_DATABASE_NAME=bitnami_wordpress --net wordpress-stack  --volume wordpress_data:/bitnami -d bitnami/wordpress:latest

Now, your containers are up and running in an isolated network (wordpress-stack).

wordpress docker blog screenshot

You can access your fresh created blog at http://localhost.

no responses for How to run WordPress with docker on Linux/macOS/Windows 10?

    Leave a Reply