Skip to content

Instantly share code, notes, and snippets.

@farid-mkh
Last active June 3, 2024 10:21
Show Gist options
  • Select an option

  • Save farid-mkh/53a72d9ce6cb2ef82e612fd2b5931feb to your computer and use it in GitHub Desktop.

Select an option

Save farid-mkh/53a72d9ce6cb2ef82e612fd2b5931feb to your computer and use it in GitHub Desktop.
Wordpress with docker

How to make wordpress website with wordpress image and mariadb

  1. Create a docker-compose.yaml

From wordpress official image

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:
  1. Open a termianl (in your directory) then type:
docker compose up

or

docker compose up -d
  1. Done!

Note: volumes: - 'wordpress:/var/www/html' will map your directory to this path in wordpress docker image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment