Help us understand the problem. What is going on with this article?

WordPressの公式Dockerをサブディレクトリで使う方法

More than 1 year has passed since last update.

概要

WordPressの公式Dockerをサブディレクトリで使いたいです。
例えば、http://example.com/blog/ でアクセスしたい。

この問題の対処法をぐぐるといくつかやり方が出て来ますが、良い方法が検索上位に来ていないので、インデックス用に記事を書きました。

結論

以下の方法を使うと良いです
https://github.com/docker-library/wordpress/pull/133#issuecomment-383199445

具体例 (docker-compose.yml)

version: '2'
services:
  blog:
    image: wordpress:4.9.8
    restart: always
    ports:
      - 8080:80
    volumes:
    - "/path/to/blog_store:/var/www/html/blog"
    working_dir: /var/www/html/blog # <- これがポイント
    links:
    - mysql:mysql-host
    environment:
      WORDPRESS_DB_HOST: mysql-host:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
  mysql:
    image: mysql:5.7
    volumes:
    - "/path/to/db_store:/var/lib/mysql"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away