プログラムを中心とした個人的なメモ用のブログです。 タイトルは迷走中。
内容の保証はできませんのであしからずご了承ください。

2017/10/13

Redmine を docker-compose で動かしてみる

event_note2017/10/13 2:35

公式の Docker イメージを使用して Redmine を docker-compose で動かしてみます。

データベースは MySQL を使用します。
理由は、現在 Bitnami Redmine を使用しており、そこからの移行を目的としているためです。

docker-compose.yml

とりあえず作成した docker-compose.yml は以下です。

version: '2'
services:
  redmine:
    image: redmine
    restart: always
    ports:
      - 3000:3000
    environment:
      - REDMINE_DB_MYSQL=mysql
      - REDMINE_DB_PASSWORD=example
    volumes_from:
      - redmine-datastore
  redmine-datastore:
    container_name: redmine-datastore
    image: busybox
    volumes:
      - /usr/src/redmine/files
  mysql:
    container_name: redmine-mysql
    image: mysql
    command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_DATABASE: redmine
    volumes_from:
      - mysql-datastore
  mysql-datastore:
    container_name: redmine-mysql-datastore
    image: busybox
    volumes:
      - /var/lib/mysql

後述しますが、MySQL については文字コードを変更しないとエラーが表示されます。

MySQL の文字コードを変更

Redmine に管理者でログイン後、管理メニューでデフォルト設定がロードできますが、当初ここで以下のようなエラーが表示されました。

デフォルト設定がロードできませんでした: Mysql2::Error: Incorrect string value:

調べたところ、これは MySQL の文字コードに起因しているようです。
なので、MySQL の文字コードを変更します。
docker-compose.yml の中の以下のコードが文字コードを変更している箇所です。

command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci

参考 URL