created: 2020-11-27T08:05:07.000Z

WordPressをdocker-composeでサッとたてる

wordpressを手元でさくっと立ち上げたい時があったので、docker-composeでたててみた

.docker 配下にボリュームをつくってデータを永続化している

version: "2"
services:
  wp:
    image: wordpress:latest
    restart: always
    volumes:
      - ".docker/wp/var/www/html:/var/www/html"
    ports:
      - "127.0.0.1:8000:80"
    depends_on:
      - db
    environment:
      WORDPRESS_DB_HOST: "db:3306"
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress

  db:
    image: mysql:5.7
    restart: always
    volumes:
      - ".docker/db/var/lib/mysql:/var/lib/mysql"
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

参考