Toronto, Canada · Support hours Mon–Fri, 9 AM–5 PM ET
+1-647-578-8440 +1-800-406-7400 (US & Intl)

How to run Wordpress & Mysql with docker-compose and custom php.ini

Rez Moss 1 min read
How to run Wordpress & Mysql with docker-compose and custom php.ini

1- Save this as docker-compose.yml:

            version: "3.3"
                
            services:
            db:
                image: mysql:5.7
                volumes:
                - ${PWD}/db_data:/var/lib/mysql
                restart: always
                environment:
                MYSQL_ROOT_PASSWORD: somewordpress
                MYSQL_DATABASE: wordpress
                MYSQL_USER: wordpress
                MYSQL_PASSWORD: wordpress
                
            wordpress:
                depends_on:
                - db
                image: wordpress:latest
                volumes:
                - ${PWD}/wordpress_data:/var/www/html
                - ./php.ini:/usr/local/etc/php/conf.d/conf.ini
                ports:
                - "8000:80"
                restart: always
                environment:
                WORDPRESS_DB_HOST: db
                WORDPRESS_DB_USER: wordpress
                WORDPRESS_DB_PASSWORD: wordpress
                WORDPRESS_DB_NAME: wordpress
            volumes:
            db_data: {}
            wordpress_data: {}

2- Save this as php.ini in the same directory:

        file_uploads = On
        memory_limit = 500M
        upload_max_filesize = 500M
        post_max_size = 500M
        max_execution_time = 3200

3- Run docker-compose up

4- WordPress stores its files in the “wordpress_data” folder and MySQL stores its data in “db_data”, both in the same directory as the compose file. The site listens on port 8000, so open http://localhost:8000 in your browser to reach WordPress.

Need expert advice? Schedule your AWS consultation today!

Schedule now

Keep reading

All articles →
migration 4 min read

Migrating from On-Premises Servers to AWS EC2 Benefits and Step-by-Step Guide

Why moving on-premises servers to AWS EC2 pays off in cost, scale, and uptime, plus a four-step plan: assess, plan, migrate, optimize.

Read article →
aws 5 min read

Understanding AWS Lambda Pricing - A Comprehensive Breakdown

How AWS Lambda pricing works, how it compares with EC2, and practical ways to cut your Lambda bill.

Read article →
aws 5 min read

Top 5 Innovative Uses of AWS Lambda in Modern Web Applications

Five practical uses of AWS Lambda in web applications: real-time data processing, scheduled tasks, serverless APIs, IoT backends, and security …

Read article →

Need expert help with AWS?

Book a consultation or pick a support plan. Certified engineers answer during business hours, and you can cancel anytime.

See pricingContact us