Deploy WordPress with MySQL on Docker in less than 3 minutes

First Make a WordPress Docker Project Directory

$ mkdir -p /u01/my_wordpress

$ vim docker-compose.yml

version: ‘3.3’

services:
db:
image: mysql:5.7
volumes:
– 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
ports:
– “8000:80”
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}

  • The Docker volume db_data persists any updates made by WordPress to the database.
  • WordPress Multisite works only on ports 80 and 443.

Now, run docker-compose up -d from your project directory. If it is not available install it using YUM

$ sudo yum install docker-compose

$ docker-compose up -d

Creating network “mywordpress_default” with the default driver
Creating volume “mywordpress_db_data” with default driver
Pulling db (mysql:5.7)…

Go to your Browser http://ip-address-local-machine:8000/ and start setup of WordPress

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s