Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Wordpress Dev env with Docker

Makesure docker is installed: check version by

sudo docker --version

Create the dev folder and create docker-compose.yml:

mkdir wordpress_dev
vim docker-compose.yml

Paste following and save the file: docker-compose.yml

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     ports:
       - "3306:3306"
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     volumes:
       - ./wp-content:/var/www/html/
     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
volumes:
    db_data:

Then start your wordpress docker container by:

sudo docker-compose up -d

Open localhost:8000 on web-browser

To stop the container:

sudo docker-compose down

That's all, wordpres dev folders will be availble in /wordpress folder


[1] Keeps the database intact when container is stopped. [2] Exposes the development folders inside wordpress

[1]
volumes:
       - db_data:/var/lib/mysql

[2]
volumes:
   - ./wp-content:/var/www/html/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.