How to run a Local Wordpress + Nginx Instance using Docker

DockerWordpressPHP
February 12, 2023

When we want to develop locally it’s generally handy to have a local version of Wordpress running. This can be done using a Docker container with Nginx and Wordpress out of the box, so you’re good to go in 5 minutes.

1. Install Docker for Desktop

Go to https://www.docker.com/get-started/ And install Docker desktop.

2. Pull Bitnami’s Wordpress & Nginx container

Open up a terminal. Make a project folder somewhere in the terminal.

mkdir mywordpress cd mywordpress

Pull in Bitnami’s Wordpress & Nginx container.

docker pull bitnami/wordpress-nginx:latest

3. Create the Docker compose file.

After that’s done, make a new file called docker-compose.yml using vim or node.

vim docker-compose.yml

Paste this configuration in the freshly created docker-compose.yml

version: '2' services: mariadb: image: docker.io/bitnami/mariadb:10.6 volumes: - './mariadb_data:/bitnami/mariadb' environment: # ALLOW_EMPTY_PASSWORD is recommended only for development. - ALLOW_EMPTY_PASSWORD=yes - MARIADB_USER=bn_wordpress - MARIADB_DATABASE=bitnami_wordpress wordpress: image: docker.io/bitnami/wordpress-nginx:5 ports: - '80:8080' - '443:8443' volumes: - './wordpress_data:/bitnami/wordpress' depends_on: - mariadb environment: # ALLOW_EMPTY_PASSWORD is recommended only for development. - ALLOW_EMPTY_PASSWORD=yes - WORDPRESS_DATABASE_HOST=mariadb - WORDPRESS_DATABASE_PORT_NUMBER=3306 - WORDPRESS_DATABASE_USER=bn_wordpress - WORDPRESS_DATABASE_NAME=bitnami_wordpress volumes: mariadb_data: driver: local wordpress_data: driver: local

And save it!

4. Run the application using Docker Compose

In the same folder where your docker-compose.yml is located, run:

docker-compose up

5. Finished!

You successfully set up a Nginx stack with Wordpress installed.

You’re now able to visit your local Wordpress through:

  • http://localhost:80
  • https://localhost:443

How do I log in the WP-admin?

Go to https://localhost:443/wp-admin and log in with the following credentials:

  • Username: user
  • Password: bitnami

Where can I find the Wordpress files on my local drive?

As you can see in the docker-compose.yaml file, there’s a folder being made called wordpress_data You can open this folder with your favorite IDE or Text editor and edit files directly.

How do I further configure my Local Nginx + Wordpress Stack?

Have a look at the Bitnami’s docker-wordpress-nginx repo.

Source: https://hub.docker.com/r/bitnami/wordpress-nginx/