How to create a Wordpress instance using docker-compose.
- 05 Sep, 2017
Docker containers are like magic. You can create a wodpress instance in minutes.
Today i create a docker-compose.yml file for a Wordpress inance.
Just create the file with the commands bellow and you will get a Wordpress site. You will not loose the customizations because they are saved on the host machine.
Create the folders /wp-content and wp-content/uploads bellow the folder that contains docker-compose.yml. I test this instance only on my Mac for development.
version: ‘3’
services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: rootpassword MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: yourpassword
wordpress: depends_on: - db image: wordpress:latest volumes: - ./wp-content/uploads:/var/www/html/wp-content/uploads - ./wp-content:/var/www/html/wp-content ports: - “8000:80” restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: yourpassword volumes: db_data: