Are you looking to set up a WordPress website with a MariaDB database using Docker? Docker provides a convenient way to create and manage containers, allowing you to run applications in isolated environments. In this tutorial, we’ll guide you through the process of creating a Docker Compose file for WordPress and MariaDB.
Before we begin, make sure you have Docker and Docker Compose installed on your system. You can download them from the official Docker website.
Step 1: Create a New Directory
Start by creating a new directory for your project. Open a terminal and run the following command:
$ mkdir wordpress-mariadb
Step 2: Create a Docker Compose File
Next, navigate to the newly created directory:
$ cd wordpress-mariadb
Now, create a new file called
docker-compose.yml using your preferred text editor:
$ nano docker-compose.yml
Within this file, you’ll define the services for WordPress and MariaDB.
Step 3: Configure MariaDB
First, let’s configure the MariaDB service. Add the following code to your
Make sure to replace
your_wordpress_user_password with your desired values.
Step 4: Configure WordPress
Next, let’s configure the WordPress service. Add the following code below the MariaDB configuration:
your_wordpress_user_password with the appropriate values.
Step 5: Start the Containers
docker-compose.yml file and close the text editor. In the terminal, run the following command to start the containers:
$ docker-compose up -d
This command will pull the necessary Docker images (if not already available) and start the WordPress and MariaDB containers in detached mode.
Step 6: Access Your WordPress Site
Once the containers are up and running, you can access your WordPress site by opening a web browser and navigating to
http://localhost:8080. You should see the WordPress setup page where you can configure your site.
By following these steps, you’ve successfully created a Docker Compose file for running WordPress with a MariaDB database. Docker provides a convenient and reproducible way to set up and manage your WordPress environment. Feel free to customize the configuration to suit your specific requirements.