Docker Compose – wordpress

Docker Compose - wordpress

Simple steps to start using docker compose to create wordpress dockers.

Installation

Install docker-compose package

Run following command on ubuntu and armbian servers.

apt install docker-compose

Create dockers

Create folder as project name wp

The project name will be used as a part of docker container name.

mkdir -p /app/wp

Create docker compose file

Using vi to create file docker-compose.yml in directory /app/wp

version: "3.3"

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

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    volumes:
      - wordpress_data:/var/www/html
    ports:
      - "80:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
volumes:
  db_data: {}
  wordpress_data: {}

Run docker compose command

docker-compose up -d

Destroy dockers

Run docker compose command

docker-compose down

Destroy dockers and their volumes

docker-compose down --volumes

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


The reCAPTCHA verification period has expired. Please reload the page.