Automate Marketing Initiatives with Salesforce Marketing Cloud Learn More

Quick Guide to Implement WordPress On Docker in Just 10 Min?

WordPress is an opensource, easy to build CMS (Content Management System) proudly built with a combination of PHP and MySQL. It is barely impossible that a person doesn’t know about it or hasn’t heard about WordPress. WordPress is a popular choice for a Web Developer when creating different types of websites, from blogs to eCommerce sites.

 

To run a WordPress site, we need LAMP (Linux, Apache, MySQL, and PHP) or LEMP (Linux, Nginx, MySQL, and PHP) stack, which can take time 3 times meaning local, staging, and production servers. However, by using Docker and Docker Compose, we can simplify the process of setting up preferred stack and installing WordPress. What Is Docker? – Docker is open-source software that creates environments to build, share and run an application. Hence, you develop, test, and run multiple applications on the same machine.

 

In this article, we will build a multi-container WordPress install means WordPress Containerization With Docker, so we are going to create containers for MySQL Database, PhpMyAdmin, and WordPress itself.

Installation

Install Docker: To install Docker CE please follow the official website, based on your Operation System. 

Install Docker Compose : To install Docker CE please follow the official website, based on your Operation System.  

Setup WordPress on Docker

Let’s move forward and configure our Docker compose for WordPress. One can do this by using Docker CLI, but here we are going to follow the more simple and systematic method that Docker compose. 

  1. Create a new Directory “wordpress” for WordPress:
    mkdir ~/wordpress/

    then move into it: 

    cd ~/wordpress/
  2. Create a new folder “.docker” in the newly created folder, this folder will contain all our extra config files:
    mkdir .docker
  3. In this “.docker” folder create a file called “uploads.ini”, as the name stats it will provide us control on PHP configurations. Let’s put the content below, you can modify these or addon more based on your project needs –
    file_uploads = On 
    memory_limit = 128M 
    upload_max_filesize = 128M 
    post_max_size = 128M 
    max_execution_time = 120
  4. Now create a file in “.docker” folder called “php-apache.conf”, this will set up Virtual Host for our us. Paste the content below, you can modify these or addon more based on your project needs –
    # Virtual Hosts 
    # 
    <VirtualHost *:80> 
        ServerAdmin webmaster@assetlibrary.test 
        DocumentRoot "/var/www/html" 
        ServerName example.wordpress 
        #ErrorLog "logs/example.wordpress-error.log" 
        #CustomLog "logs/example.wordpress-access.log" common 
    </VirtualHost>

     

  5. Now let’s create a file “.env” in root folder that is “wordpress” this file contains all environment variables DB details etc., and paste the below content into it –
    # The table prefix (Required) of the WordPress database used in our website 
    # Ex. wp_ 
    db_table_prefix=wp_ 
      
    # You can disable any of the plugins that are not needed for development, ex. Bulletproof Security or any SEO plugin. 
    # Comma (,) separated list as a string (no spaces), leave blank if you don't want to disable plugins.  
    # Ex. plugin-folder-name-1,plugin-folder-name-2 
    wp_plugins_to_disable=  
    wp_debug_mode=0 
      
    #################################################### 
    ### Defaults - can be left as it is for basic usage #################################################### 
    db_host=assetsdb 
    db_user=asset_user 
    db_password=asset_pwd 
    db_name=asset_db 
    db_root_password=root 
    db_port=3309

     

  6. Now let’s create a file called “docker-compose.yml”, here this is the main file that holds all the docker configurations for us. Paste the content below in the file. 
     
    Let’s understand a little about the configuration from this file. As you can see there are 2 heads of services and volumes 
    A. There are 3 services dbwordpress, and phpmyadmin –
    db: Used official mysql image for this service, you can have a look here. 
    wordpress: I used an official wordpress image for this service, you can have a look here. 
    phpmyadmin: I used an official phpmyadmin image for this service, you can have a look here. 
     
    B. There is a volume named persistent, that is used for mysql. It means that our DB volume will be persistent whenever we start the container. One can change this name if he wants to, I used persistent to remember its feature.
        version: "3.9" 
             
        services: 
            db: 
                container_name: assetsdb 
                image: mysql 
                volumes: 
                    - ./dump:/docker-entrypoint-initdb.d 
                    - persistent:/var/lib/mysql 
                restart: always 
                ports:  
                    - '3309:3306' 
                environment: 
                    MYSQL_ROOT_PASSWORD: $db_root_password 
                    MYSQL_DATABASE: $db_name 
                    MYSQL_USER: $db_user 
                    MYSQL_PASSWORD: $db_password 
          
            wordpress: 
                #depends_on: 
                #  - db 
                links: 
                    - db 
                image: wordpress:latest 
                volumes: 
                    - ./wp-content:/var/www/html/wp-content 
                    - ./apache-logs:/var/log/apache2 
                    - ./.docker/php-apache.conf:/etc/apache2/sites-enabled/000-default.conf 
                    - ./.docker/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini 
                ports: 
                    - "80:80" 
                restart: always 
                environment: 
                    WORDPRESS_DB_HOST: $db_host 
                    WORDPRESS_DB_USER: $db_user 
                    WORDPRESS_DB_PASSWORD: $db_password 
                    WORDPRESS_DB_NAME: $db_name 
                    WORDPRESS_TABLE_PREFIX: $db_table_prefix 
                    WORDPRESS_DEBUG: $wp_debug_mode 
                    DISABLED_PLUGINS: $wp_plugins_to_disable 
                           
            phpmyadmin: 
                image: phpmyadmin 
                restart: always 
                ports: 
                    - 8089:80 
                links:  
                    - db:db 
                environment: 
                    MYSQL_USER: $db_user 
                    MYSQL_PASSWORD: $db_password 
                    MYSQL_ROOT_PASSWORD: $db_root_password 
               
        volumes: 
            persistent: 
  7. This is an optional step to follow, that is to add our Virtual Host in Operating System’s host file. 
    For Windows, with Administrative rights:  
    Hosts file (hosts) location of the in windows – c:\Windows\System32\Drivers\etc\hosts 
    For Linux, with root access use following command:
    sudo nano /etc/hosts

    Append the following line in the file: 

    127.0.0.1 example.wordpress

    Now you are ready to use your WordPress installation at the domain http://example.wordpress after running the container and then install WordPress in Docker Container. 

Usage

Build, (re)create, start, and attache to containers

You can start the container with the up command in Daemon Mode (by adding -d as an argument). Your WordPress will be running and available at this link http://127.0.0.1:80. 

docker-compose up

Starting containers 

 Start existing containers using the start command –

docker-compose start

Stopping containers 

docker-compose stop

Removing containers 

The use of down command will stop and remove all the containers –

docker-compose down

Use -v if you need to delete the database volume that is used to maintain the database –

docker-compose down –v

PhpMyAdmin 

You will have to visit http://127.0.0.1:8081 to access phpMyAdmin after starting the container. 

 

MySQL default username is root, and the password is the same as supplied in the .env file. 

 

Please go through the official documentation here for more commands in details. 

A place for big ideas.

Reimagine organizational performance while delivering a delightful experience through optimized operations.

Conclusion

Docker is the best open-source software tool to create containers. Its simple environment configuration helps us in maintaining server resources. When we want simple and ready to use environment on each level of the SDLC (Software Development Life Cycle) Docker is a favorite tool.

 

In this article, we have learned Docker basics and how we can setup WordPress in Docker using Docker Compose. I hope this article will be helpful, we will glad to help you in any of your queries so please be open to ask any questions in the future.

 

Top Stories

How to Connect WooCommerce to Odoo
How to Connect WooCommerce to Odoo — Complete Setup Guide
Connecting WooCommerce to Odoo does not require a developer, a middleware tool, or weeks of implementation. The Zehntech Odoo WooCommerce Connector gives you real-time bi-directional sync between your WooCommerce store and your Odoo backend — set up in under 15 minutes. This guide is for Odoo administrators, eCommerce operations managers,
How to Connect Odoo to ShipStation — Step by Step Setup Guide
How to Connect Odoo to ShipStation A Step-by-Step Setup Guide
This guide walks you through connecting Odoo to ShipStation using the Zehntech Odoo ShipStation Connector — from generating your API credentials in ShipStation to your first automated order push and tracking import. Most setups take under 10 minutes. Prerequisites Before you begin: Odoo version: v17, v18 or v19 (Online, Odoo.sh
AI Agents Are Transforming Odoo ERP Operations in 2026
How AI Agents Are Transforming Odoo ERP Operations in 2026
Most ERP systems already hold the information needed to make better decisions. The problem is the work between the data and the decision: opening several modules, filtering records, exporting spreadsheets, comparing numbers and then updating Odoo manually. AI agents are beginning to remove that gap. Unlike a chatbot that only
Connect Odoo & Shopify Automatically in 2026
How to Connect Odoo and Shopify Automatically (2026 Guide)
If you're running Shopify for your storefront and Odoo for everything behind it — inventory, accounting, fulfillment — you already know the two don't talk to each other out of the box. This guide walks through exactly how to connect them so orders, stock, and customer data sync automatically, with
Odoo Hubspot Connector
How to connect hubSpot to odoo a step-by-step setup guide
This guide walks you through connecting HubSpot to Odoo using the Zehntech Odoo HubSpot Connector from generating your API key in HubSpot to your first live sync. Most teams complete this in under 10 minutes. Prerequisites Before you begin: Odoo version: v16, v17, v18 or v19 (Online, Odoo.sh or On-Premise)
Odoo AI: How AI Agents Are Automating Business Operations in 2026
Odoo+AI: How AI Agents Are Automating Business Operations in 2026
Your Odoo system knows everything about your business. It knows which products are below reorder level right now. It knows which purchase orders are overdue. It knows which outlets sold below target yesterday and which customers are approaching their credit limit. Your team does not know any of this until

          Success!!

          Keep an eye on your inbox for the PDF, it's on its way!

          If you don't see it in your inbox, don't forget to give your junk folder a quick peek. Just in case.



              You have successfully subscribed to the newsletter

              There was an error while trying to send your request. Please try again.

              Zehntech will use the information you provide on this form to be in touch with you and to provide updates and marketing.