docker上でredmineを動かす のバックアップソース(No.6)

更新

[[公開メモ]]

* 目次 [#sb245dfa]

#contents

* 概要 [#ac4e4f55]

Debian 上に Docker を入れ、その上で Redmine を動かして、いろいろ便利に使いたい。

Docker も Redmine も素人なのでだましだましです。

* Docker のインストール [#q0af0818]

独立した仮想マシンを1つのプロセスとして立ち上げられるコンテナ実行環境。

Debian 用のインストラクション通りにすれば簡単だった~
https://docs.docker.com/install/linux/docker-ce/debian/

 LANG:console
 $ uname -r                      # >= 3.2 でなければならないらしい
  3.16.0-4-amd64
 $ sudo apt-get update           # 以下、docker 配布元を apt-source に入れる
 $ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
 $ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
  OK
 $ sudo apt-key fingerprint 0EBFCD88 | grep -4 0EBFCD88 # should have finger print 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
  pub   1024D/97BB3B58 2007-04-30 [失効: 2014-11-24]
                   指紋 = 3EC0 AFB9 4A84 5900 282E  7A55 B5B7 7200 97BB 3B58
  uid                  Emdebian Archive Signing Key
  
  pub   4096R/0EBFCD88 2017-02-22
                   指紋 = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
  uid                  Docker Release (CE deb) <docker@docker.com>
  sub   4096R/F273FCD8 2017-02-22
 $ lsb_release -cs       # jessie の文字を得る
  jessie
 $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
 $ sudo apt-get update           # 配布元からの情報を元に最新の docker-ce をインストール
 $ sudo apt-get install docker-ce
  以下の追加パッケージがインストールされます:
    aufs-tools cgroupfs-mount mountall pigz plymouth
  提案パッケージ:
    desktop-base plymouth-themes
  以下のパッケージが新たにインストールされます:
    aufs-tools cgroupfs-mount docker-ce mountall pigz plymouth
  アップグレード: 0 個、新規インストール: 6 個、削除: 0 個、保留: 9 個。
  34.2 MB 中 33.8 MB のアーカイブを取得する必要があります。
  この操作後に追加で 186 MB のディスク容量が消費されます。
 $ sudo docker info              # もう入っている
  Containers: 1
   Running: 0
   Paused: 0
   Stopped: 1
  Images: 1
  Server Version: 18.03.0-ce
  Storage Driver: aufs
   Root Dir: /var/lib/docker/aufs
   Backing Filesystem: extfs
   Dirs: 3
   Dirperm1 Supported: true
  Logging Driver: json-file
  Cgroup Driver: cgroupfs
  Plugins:
   Volume: local
   Network: bridge host macvlan null overlay
   Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
  Swarm: inactive
  Runtimes: runc
  Default Runtime: runc
  Init Binary: docker-init
  containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
  runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
  init version: 949e6fa
  Kernel Version: 3.16.0-4-amd64
  Operating System: Debian GNU/Linux 8 (jessie)
  OSType: linux
  Architecture: x86_64
  CPUs: 2
  Total Memory: 1.929GiB
  Name: dora
  ID: 4NF2:A23G:EHHR:XF6I:VR25:U7EH:OXZK:AQ7A:GEAO:24H7:A623:KHQ7
  Docker Root Dir: /var/lib/docker
  Debug Mode (client): false
  Debug Mode (server): false
  Registry: https://index.docker.io/v1/
  Labels:
  Experimental: false
  Insecure Registries:
   127.0.0.0/8
  Live Restore Enabled: false
  
  WARNING: No memory limit support
  WARNING: No swap limit support
  WARNING: No kernel memory limit support
  WARNING: No oom kill disable support
  WARNING: No cpu cfs quota support
  WARNING: No cpu cfs period support
 $ sudo docker run hello-world
  Unable to find image 'hello-world:latest' locally
  latest: Pulling from library/hello-world
  9bb5a5d4561a: Pull complete
  Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
  Status: Downloaded newer image for hello-world:latest
  
  Hello from Docker!
  This message shows that your installation appears to be working correctly.
  
  To generate this message, Docker took the following steps:
   1. The Docker client contacted the Docker daemon.
   2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
      (amd64)
   3. The Docker daemon created a new container from that image which runs the
      executable that produces the output you are currently reading.
   4. The Docker daemon streamed that output to the Docker client, which sent it
      to your terminal.
  
  To try something more ambitious, you can run an Ubuntu container with:
   $ docker run -it ubuntu bash
  
  Share images, automate workflows, and more with a free Docker ID:
   https://hub.docker.com/
  
  For more examples and ideas, visit:
   https://docs.docker.com/engine/userguide/
 $ sudo docker images
  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
  hello-world         latest              e38bc07ac18e        13 days ago         1.85kB

こうして入れておけば、後々 apt-get update と apt-get upgrade で常に docker を最新の状態に保てる。

* docker へのアクセスを許す人を docker グループに入れる [#w80e5ac0]

docker グループに入っている人は sudo なしで docker コマンドを使えるそうだ~
https://qiita.com/DQNEO/items/da5df074c48b012152ee

 LANG:console
 $ sudo grep docker /etc/group       # グループ自体はすでに存在する
  docker:x:135:
 $ sudo gpasswd -a takeuchi docker
  ユーザ takeuchi をグループ docker に追加
 $ sudo service docker restart       # docker を再起動
 $ exit                              # 再ログインが必要?

再度ログインして、

 LANG:console
 $ docker images
  REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
  hello-world            latest              e38bc07ac18e        13 days ago         1.85kB
 $

確かに sudo なしで使えている。

* docker-composer のインストール [#ff6d2736]

.yml ファイルにまとめた Docker コンテナの起動方法を元にコンテナを起動してくれる便利ツール。

https://docs.docker.com/compose/install/ の Linux ページから

 LANG:console
 $ sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
 $ sudo chmod +x /usr/local/bin/docker-compose
 $ docker-compose --version
  docker-compose version 1.21.0, build 5920eb0
 $

* Redmine サービスの起動設定 [#kd135d28]

ちまたで評判の良い sameersbn/redmine を使う。

https://registry.hub.docker.com/u/sameersbn/redmine/ ~
http://snickerjp.blogspot.jp/2017/03/migrate-bitnamiredmine-to-docker-redmine.html

上記のページにはプラグインをバリバリ使うには 2.6 系統を使うと良いと書かれているが、
ググった限り 3.4 などの新しいものを実用している記述も多くあるため、
ここでも最新版を入れておく。

docker-compose.yml に設定を書いておくと、実際のインストールは
docker-compose が自動的にやってくれるので、設定のひな形を落としてきてそれを編集する。

 LANG:console
 $ mkdir ~/bklan       # redmine コンテナの起動設定を保存しておくフォルダ
 $ cd ~/bklan          # このフォルダ名がコンテナ名のプレフィックスになる
 $ wget https://raw.githubusercontent.com/sameersbn/docker-redmine/master/docker-compose.yml
 $ cat docker-compose.yml    # これが起動設定の規定値 YAML で書かれている
  version: '2'
  
  services:
    postgresql:        # データベースサーバーのコンテナ
      image: sameersbn/postgresql:9.6-2
      environment:     # 最低限 DB_PASS は設定しておく
      - DB_USER=redmine
      - DB_PASS=password
      - DB_NAME=redmine_production
      volumes:         # データの格納場所
      - /srv/docker/redmine/postgresql:/var/lib/postgresql
  
    redmine:           # Redmine サーバーのコンテナ
      image: sameersbn/redmine:3.4.4-2
      depends_on:
      - postgresql
      environment:     # 上で設定したのと同じ DB_PASS を記入する TZ を Asia/Tokyo
      - TZ=Asia/Kolkata
  
      - DB_ADAPTER=postgresql
      - DB_HOST=postgresql
      - DB_PORT=5432
      - DB_USER=redmine
      - DB_PASS=password
      - DB_NAME=redmine_production
  
      - REDMINE_PORT=10083
      - REDMINE_HTTPS=false
      - REDMINE_RELATIVE_URL_ROOT=
      - REDMINE_SECRET_TOKEN=
  
      - REDMINE_SUDO_MODE_ENABLED=false
      - REDMINE_SUDO_MODE_TIMEOUT=15
  
      - REDMINE_CONCURRENT_UPLOADS=2
  
      - REDMINE_BACKUP_SCHEDULE=
      - REDMINE_BACKUP_EXPIRY=
      - REDMINE_BACKUP_TIME=
  
      - SMTP_ENABLED=false
      - SMTP_METHOD=smtp
      - SMTP_DOMAIN=www.example.com
      - SMTP_HOST=smtp.gmail.com
      - SMTP_PORT=587
      - SMTP_USER=mailer@example.com
      - SMTP_PASS=password
      - SMTP_STARTTLS=true
      - SMTP_AUTHENTICATION=:login
  
      - IMAP_ENABLED=false
      - IMAP_HOST=imap.gmail.com
      - IMAP_PORT=993
      - IMAP_USER=mailer@example.com
      - IMAP_PASS=password
      - IMAP_SSL=true
      - IMAP_INTERVAL=30
  
      ports:           # Docker の外からの 10083番 へのアクセスを Docker 内の 80番 に繋ぐ
      - "10083:80"
      volumes:         # データの格納場所
      - /srv/docker/redmine/redmine:/home/redmine/data
 $ # パスワード等を適切に設定する

2カ所の DB_PASS と REDMINE_SECRET_TOKEN、 TZ は設定しておく。

REDMINE_SECRET_TOKEN を設定しなければ代わりにランダム文字列が使われる。
コンテナを起動し直したときに変わってしまうのだとセッションが切れてしまうので、
たぶん自分で設定しておいた方が良い?あるいはコンテナを起動し直しても値は変わらない?
(未調査)

volumes に記述してあるデータ格納場所も、変更したければする。

* コンテナを起動する [#o0c96aeb]

初回起動時に自動的にイメージがダウンロードされる。

2回目からは同じイメージが再利用される。

 LANG:console
 $ docker-compose up
  Pulling postgresql (sameersbn/postgresql:9.6-2)...
  9.6-2: Pulling from sameersbn/postgresql
  c60055a51d74: Already exists
  755da0cdb7d2: Already exists
  969d017f67e6: Already exists
  37c9a9113595: Already exists
  a3d9f8479786: Already exists
  e43d9de53575: Already exists
  cddf24084b61: Already exists
  f23b95c5f17c: Already exists
  3965edbc705f: Already exists
  4e6c393fb7f5: Already exists
  Digest: sha256:884ccbac79c1d3daa39c07e7e1f2e5cc11ce18e2c5e41ac146258b9715f1d6c4
  Status: Downloaded newer image for sameersbn/postgresql:9.6-2
  Pulling redmine (sameersbn/redmine:3.4.4-2)...
  3.4.4-2: Pulling from sameersbn/redmine
  cb56c90f0b30: Already exists
  0acc551e5716: Already exists
  8956dcd35143: Already exists
  908242721214: Already exists
  b44ff14dd3bb: Already exists
  707fcc5f355b: Already exists
  10c1e51efdb9: Already exists
  f093a86acbb1: Already exists
  f923a64ff0ea: Already exists
  79fd4a3a1d5d: Already exists
  eaec5aaae3b9: Already exists
  3288d3231956: Already exists
  Digest: sha256:2aa94011113acbe260debe580d8259f325027b5ad68e6ecb7d4fa6692bddee1b
  Status: Downloaded newer image for sameersbn/redmine:3.4.4-2
  Starting bklan_postgresql_1 ... done
  Starting bklan_redmine_1    ... done
  Attaching to bklan_postgresql_1, bklan_redmine_1
  postgresql_1  | Initializing datadir...
  redmine_1     | Initializing logdir...
  redmine_1     | Initializing datadir...
  redmine_1     | Symlinking dotfiles...
  redmine_1     | Installing configuration templates...
  redmine_1     | Configuring redmine...
  postgresql_1  | Initializing certdir...
  postgresql_1  | Initializing logdir...
  postgresql_1  | Initializing rundir...
  postgresql_1  | Setting resolv.conf ACLs...
  postgresql_1  | Creating database user: redmine
  postgresql_1  | Creating database: redmine_production...
  postgresql_1  | &#8227; Granting access to redmine user...
  postgresql_1  | Starting PostgreSQL 9.6...
  postgresql_1  | LOG:  database system was shut down at 2018-04-24 18:30:39 UTC
  postgresql_1  | LOG:  MultiXact member wraparound protections are now enabled
  postgresql_1  | LOG:  database system is ready to accept connections
  postgresql_1  | LOG:  autovacuum launcher started
  redmine_1     | Configuring redmine::database...
  redmine_1     | Configuring redmine::unicorn...
  redmine_1     | Configuring redmine::secret_token...
  redmine_1     | Configuring redmine::max_concurrent_ajax_uploads...
  redmine_1     | Configuring redmine::sudo_mode...
  redmine_1     | Configuring redmine::autologin_cookie...
  redmine_1     | Configuring redmine::backups...
  redmine_1     | Configuring nginx...
  redmine_1     | Configuring nginx::redmine...
  redmine_1     | Installing plugins...
  redmine_1     | Installing themes...
  redmine_1     | 2018-04-25 00:00:41,895 CRIT Supervisor running as root (no user in config file)
  redmine_1     | 2018-04-25 00:00:41,895 WARN Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
  redmine_1     | 2018-04-25 00:00:41,895 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  redmine_1     | 2018-04-25 00:00:41,896 WARN Included extra file "/etc/supervisor/conf.d/unicorn.conf" during parsing
  redmine_1     | 2018-04-25 00:00:41,928 INFO RPC interface 'supervisor' initialized
  redmine_1     | 2018-04-25 00:00:41,928 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  redmine_1     | 2018-04-25 00:00:41,929 INFO supervisord started with pid 1
  redmine_1     | 2018-04-25 00:00:42,931 INFO spawned: 'unicorn' with pid 229
  redmine_1     | 2018-04-25 00:00:42,933 INFO spawned: 'cron' with pid 230
  redmine_1     | 2018-04-25 00:00:42,935 INFO spawned: 'nginx' with pid 231
  redmine_1     | 2018-04-25 00:00:44,362 INFO success: unicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  redmine_1     | 2018-04-25 00:00:44,362 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  redmine_1     | 2018-04-25 00:00:44,362 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

これで http://localhost:10083 へ繋ぐと Redmine の初期ページを確認できる。

このとき、ファイアーウォールで遮断していない限りは外部から http://this.server.com:10083/ 
へのアクセスでも Redmine にアクセスできてしまうので注意が必要。

上記の起動方法だとフォアグラウンドに docker コンテナが起動しているので、^C で停止できる。

 LANG:console
  ^CGracefully stopping... (press Ctrl+C again to force)
  Stopping bklan_redmine_1    ... done
  Stopping bklan_postgresql_1 ... done
 $

* デーモンとして起動 [#j8cb8fab]

~-d オプションを付けるとデーモンとして起動可能。

 LANG:console
 $ docker-compose up -d
  Starting bklan-postgresql ... done
  Recreating bklan-redmine  ... done

デーモンとして起動したものを止めるには stopする。

 LANG:console
 $ docker-compose stop
  stopping bklan_postgresql_1 ... done
  stopping bklan_redmine_1    ... done

down でない理由は次の通り。

* イメージとコンテナ [#d4fa502a]

Docker は「ディスクイメージ」を「コンテナ」に入れて起動する。

「ディスクイメージ」は初期データ、
「コンテナ」はディスクイメージを「収容(contain)」して動作するプロセスだ。

起動中のコンテナは「ディスクイメージのコピー」を書き換えながら動作する。
「ディスクイメージ」が「初期データ」だと書いたのはそういう意味。

とはいえ、物理的にディスクイメージが「コピー」されるわけではなく、
コンテナは「書き換え差分」を管理する形で動作するため、
起動時に「コピー」に時間がかかったりしないし、
例えば同じディスクイメージを複数のコンテナに入れて同時起動したとしても、
ディスクイメージを記憶しておくための領域が何倍にも膨れ上がったりしない。
すごく便利。

気をつけなければならないのは、docker ではコンテナはとても気軽に削除されてしまうこと。
当然、コンテナを削除してしまえばコンテナ内で行った変更はすべて失われてしまうのだが、
失われて構わない物のみコンテナに入れておこうというのが基本的なスタンスみたい。
永続的に取っておきたいデータはコンテナ外に保存するか、
コンテナ内の書き換え差分をイメージに書き出して残しておくのがセオリー。

例えば docker-compose では、

Unless they are already running, this command also starts any linked services
- docker-compose up : 必要に応じてイメージを build し、必要に応じてコンテナを create し start する。-d を付けない限りフォアグランドプロセスとなる。(すでに create されていれば、書き換え差分は保持)
- docker-compose start : コンテナに割り当てられた停止中のプロセスを開始(書き換え差分は保持)
- docker-compose unpause : コンテナに割り当てられた一次停止中のプロセスを再開(書き換え差分は保持)
- docker-compose pause : コンテナに割り当てられた動作中のプロセスを一次停止(書き換え差分は保持)
- docker-compose stop : コンテナに割り当てられた動作中のプロセスを停止(書き換え差分は保持)
- docker-compose down : コンテナを停止し削除する。(書き換え差分は破棄される)

となっているのだが、驚くべき事に(?)コンテナすなわち書き換え差分が削除される場合にも確認メッセージなどは表示されない。

paused と stopped の違いが分かりにくいのだけれど、^Z で抜けたか、^C で抜けたかの違いのようなもの???~
pause されたコンテナは docker ps に現れるが、stop されたコンテナは docker ps には現れない。~
stop されたコンテナを見たければ docker ps -a とする。

exited(stopped), paused, running の各状態に、start, unpause, pause, stop を掛けたときの状態遷移をまとめておく。

|       |~start|~pause|~unpause|~stop|
|~exited|running|ERROR|ERROR|exited|
|~paused|paused|ERROR|running|exited|
|~running|running|paused|ERROR|exited|

これらを確認しよう。

 LANG:console
 $ docker images
  REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
  hello-world            latest              e38bc07ac18e        13 days ago         1.85kB
  sameersbn/redmine      3.4.4-2             668873f08acc        3 months ago        679MB
  sameersbn/postgresql   9.6-2               7f79690e67e0        15 months ago       234MB

現在、3つのイメージがインストールされている。

コンテナを起動してみる。

 LANG:console
 $ docker-compose start  # バックグラウンドで起動する
  Starting postgresql ... done
  Starting redmine    ... done
 $ docker ps
  CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                            NAMES
  7d731aa62fd3        sameersbn/redmine:3.4.4-2    "/sbin/entrypoint.sh…"   40 minutes ago      Up 40 seconds       443/tcp, 0.0.0.0:10083->80/tcp   bklan_redmine_1
  27bc9d42d540        sameersbn/postgresql:9.6-2   "/sbin/entrypoint.sh"    40 minutes ago      Up 41 seconds       5432/tcp                         bklan_postgresql_1

この時点で起動しているコンテナ(プロセス)は2つで、それぞれ sameersbn/redmine:3.4.4-2 と sameersbn/postgresql:9.6-2 のイメージを収容している(コンテナ の contain は「収容する」の意味)。
(docker ps の ps はプロセススナップショットを表示するコマンド)

コンテナを pause で止めると paused となり、unpause で再開できる。

 LANG:console
 $ docker-compose pause
  Pausing bklan_postgresql_1 ... done
  Pausing bklan_redmine_1    ... done
 $ docker ps
  CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                  PORTS                            NAMES
  7d731aa62fd3        sameersbn/redmine:3.4.4-2    "/sbin/entrypoint.sh…"   43 minutes ago      Up 3 minutes (Paused)   443/tcp, 0.0.0.0:10083->80/tcp   bklan_redmine_1
  27bc9d42d540        sameersbn/postgresql:9.6-2   "/sbin/entrypoint.sh"    43 minutes ago      Up 3 minutes (Paused)   5432/tcp                         bklan_postgresql_1
 $ docker-compose unpause 
  Unpausing bklan_redmine_1    ... done
  Unpausing bklan_postgresql_1 ... done

stop で止めると docker ps に現れなくなるが、docker ps -a には現れる。(docker ps は docker container ls のエイリアス)

 LANG:console
 $ docker-compose stop
  Stopping bklan_redmine_1    ... done
  Stopping bklan_postgresql_1 ... done
 $ docker ps
  CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                  PORTS                            NAMES
 $ docker ps -a
  CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                      PORTS               NAMES
  7d731aa62fd3        sameersbn/redmine:3.4.4-2    "/sbin/entrypoint.sh…"   About an hour ago   Exited (0) 17 seconds ago                       bklan_redmine_1
  27bc9d42d540        sameersbn/postgresql:9.6-2   "/sbin/entrypoint.sh"    About an hour ago   Exited (0) 17 seconds ago                       bklan_postgresql_1

down するとコンテナが削除されるが、当然イメージは残る。

 LANG:console
 $ docker-compose down
  Removing bklan_redmine_1    ... done
  Removing bklan_postgresql_1 ... done
  Removing network bklan_default
 $ docker ps -a
  CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
 $ docker images
  REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
  hello-world            latest              e38bc07ac18e        13 days ago         1.85kB
  sameersbn/redmine      3.4.4-2             668873f08acc        3 months ago        679MB
  sameersbn/postgresql   9.6-2               7f79690e67e0        15 months ago       234MB

up するとコンテナが再作成される。再度 up すると、start と同じ動作になる?

 LANG:console
 $ docker-compose up
  Creating network "bklan_default" with the default driver
  Creating bklan_postgresql_1 ... done
  Creating bklan_redmine_1    ... done
  Attaching to bklan_postgresql_1, bklan_redmine_1
  postgresql_1  | Initializing datadir...
  redmine_1     | Initializing logdir...
  redmine_1     | Initializing datadir...
  ...
  ^CGracefully stopping... (press Ctrl+C again to force)
  Stopping bklan_redmine_1    ... done
  Stopping bklan_postgresql_1 ... done
 $ docker-compose up -d
  Starting bklan_postgresql_1 ... done
  Starting bklan_redmine_1    ... done
 $ docker-compose stop
  Stopping bklan_redmine_1    ... done
  Stopping bklan_postgresql_1 ... done
 $ docker-compose start
  Starting postgresql ... done
  Starting redmine    ... done

ちょっとだけ表示が違うのはどうしてなのか。






* イメージの削除 [#k3e9817c]

イメージを削除するには docker rmi を使うが、pause や stop されたコンテナが残っているとそのままでは削除できない。コンテナを docker rm で削除するか、あるいは docker rmi に -f を付けて無理矢理削除する。

 LANG:console
 $ docker rmi hello-world
  Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container 42b79356e6d3 is using its referenced image e38bc07ac18e
 $ docker ps
  CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
 $ docker ps -a
  CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                   PORTS               NAMES
  42b79356e6d3        hello-world         "/hello"            7 hours ago         Exited (0) 7 hours ago                       heuristic_gates
 $ docker rm 42b79356e6d3
  42b79356e6d3
 $ docker container ls -a
  CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                   PORTS               NAMES
 $ docker rmi hello-world
  Untagged: hello-world:latest
  Untagged: hello-world@sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
  Deleted: sha256:e38bc07ac18ee64e6d59cf2eafcdddf9cec2364dfe129fe0af75f1b0194e0c96
  Deleted: sha256:2b8cbd0846c5aeaa7265323e7cf085779eaf244ccbdd982c4931aef9be0d2faf

* docker-compose を使った際のコンテナ名 [#i64f6d3b]

https://qiita.com/ymm1x/items/56961f8e2ffb48b8dbe3

デフォルトでコンテナ名は (.ymlの置かれたフォルダ名)_(サービス名)_(連番) となるので、
docker-compose.yml を置くフォルダ名は分かりやすい物にすべき。

* コンテナのコンソールにアクセスする [#x8f3fa0f]

docker exec -it (コンテナ名) bash とする。

ちょうど良いので、down / up でデータが失われることを確認する。

 LANG:console
 $ docker exec -it bklan_redmine_1 bash
 root@c6392a96ffc1:/home/redmine/redmine# ls
  CONTRIBUTING.md  Rakefile      config     extra  plugins  tmp
  Gemfile          app           config.ru  files  public   vendor
  Gemfile.lock     appveyor.yml  db         lib    script
  README.rdoc      bin           doc        log    test
 root@c6392a96ffc1:/home/redmine/redmine# touch MODIFICATION # 変更を加える
 root@c6392a96ffc1:/home/redmine/redmine# ls
  CONTRIBUTING.md  README.rdoc   bin        doc    log      test
  Gemfile          Rakefile      config     extra  plugins  tmp
  Gemfile.lock     app           config.ru  files  public   vendor
  MODIFICATION     appveyor.yml  db         lib    script
 root@23d36aaa7315:/home/redmine/redmine# exit
  exit
 $ docker-compose stop
  Stopping bklan_redmine_1    ... done
  Stopping bklan_postgresql_1 ... done
 $ docker-compose start
  Starting postgresql ... done
  Starting redmine    ... done
 $ docker exec -it bklan_redmine_1 ls MODIFICATION # stop / start では消えない
  MODIFICATION
 $ docker-compose up
  bklan_postgresql_1 is up-to-date
  bklan_redmine_1 is up-to-date
  Attaching to bklan_postgresql_1, bklan_redmine_1
  postgresql_1  | Initializing datadir...
  postgresql_1  | Initializing certdir...
  postgresql_1  | Initializing logdir...
  postgresql_1  | Initializing rundir...
  ...
  ^Z
  [1]+  停止                  docker-compose up
 $ bg
  [1]+ docker-compose up &
 $ docker exec -it bklan_redmine_1 ls MODIFICATION # up では消えない
 $ docker-compose down
  redmine_1     | 2018-04-25 11:53:45,491 WARN received SIGTERM indicating exit request
  redmine_1     | 2018-04-25 11:53:45,491 INFO waiting for cron, nginx, unicorn to die
  redmine_1     | 2018-04-25 11:53:45,493 INFO stopped: nginx (exit status 0)
  Stopping bklan_redmine_1    ... done
  redmine_1     | 2018-04-25 11:53:45,758 INFO stopped: unicorn (exit status 0)
  bklan_redmine_1 exited with code 0
  postgresql_1  | LOG:  received smart shutdown request
  postgresql_1  | LOG:  autovacuum launcher shutting down
  postgresql_1  | LOG:  shutting down
  Stopping bklan_postgresql_1 ... done
  bklan_postgresql_1 exited with code 0
  Removing bklan_redmine_1    ... done
  Removing bklan_postgresql_1 ... done
  Removing network bklan_default
 $ docker-compose start
  Starting postgresql ... done
  Starting redmine    ... done
  ERROR: No containers to start
 $ docker-compose up -d
  Creating network "bklan_default" with the default driver
  Creating bklan_postgresql_1 ... done
  Creating bklan_redmine_1    ... done
 $ docker exec -it bklan_redmine_1 ls MODIFICATION # down / up では消えてしまう
  ls: cannot access MODIFICATION: No such file or directory

* データのありか [#e1655ec4]

デフォルトのままだとデータはホスト側の /srv/docker/redmine/ 以下に置かれる。

この redmine/ の部分は docker-composer.yml を置いたフォルダと同名にしておくと
コンテナ名と整合性がとれて分かりやすいはず。

Docker コンテナは一旦落とす (down) と(コミットしていない)ファイルシステムへの変更は
毎回全て失われてしまうので、取っておきたいデータはホスト側のファイルシステムに置く必要がある。

逆に、必要なデータを全てホスト側に置けば、好きなときに Docker image を削除したり、
新しいバージョンに置き換えたりできるのだ。

 LANG:console
 $ sudo ls /srv/docker/redmine/**/*
  /srv/docker/redmine/postgresql/9.6:
  main
  
  /srv/docker/redmine/redmine/backups:
  
  /srv/docker/redmine/redmine/dotfiles:
  
  /srv/docker/redmine/redmine/files:
  
  /srv/docker/redmine/redmine/plugins:
  
  /srv/docker/redmine/redmine/themes:
  
  /srv/docker/redmine/redmine/tmp:
  Gemfile.lock  VERSION  bundle  plugin_assets  plugins.sha1  thumbnails


* redmine_issue_templates プラグインの導入 [#i332c683]

 LANG:console
 $ docker exec -it bklan_redmine_1 bash
 # ls
  CONTRIBUTING.md  Rakefile      config     extra  plugins  tmp
  Gemfile          app           config.ru  files  public   vendor
  Gemfile.lock     appveyor.yml  db         lib    script
  README.rdoc      bin           doc        log    test
 # cd plugins/
 # git clone git@github.com:akiko-pusu/redmine_issue_templates.git
 # cd redmine_issue_templates/
 # git tag
  ...
  0.1.8
  0.1.9
  support-basic-feature-for-rails5
  v0.1.4.1
 # git checkout 0.1.9
  Note: checking out '0.1.9'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
  
    git checkout -b <new-branch-name>
  
  HEAD is now at 26f9aff... Merge pull request #178 from akiko-pusu/develop
 # cd ../..
 # bundle exec rake redmine:plugins:migrate RAILS_ENV=production
  Migrating redmine_issue_templates (Redmine Issue Templates plugin)...
  == 1 CreateIssueTemplates: migrating ==========================================
  ...
  == 20170317082100 AddIsDefaultToGlobalIssueTemplates: migrating ===============
  -- add_column(:global_issue_templates, :is_default, :boolean, {:default=>false, :null=>false})
     -> 0.0151s
  == 20170317082100 AddIsDefaultToGlobalIssueTemplates: migrated (0.0152s) ======
 # exit
 $ docker-compose restart
  Restarting bklan_redmine_1    ... done
  Restarting bklan_postgresql_1 ... done

http://localhost:10083/admin/plugins で "Redmine Issue Templates plugin" が現れていることを確認。

「設定」から「テンプレート一覧 / 編集」を押すと、

http://localhost:10083/global_issue_templates

へ飛んで、「グローバルテンプレート」の新規作成等ができる。

* logs の確認 [#y6857090]

コンテナのログを確認できるらしい。

 LANG:console
  $ docker logs bklan_redmine_1
  Initializing logdir...
  Initializing datadir...
  Symlinking dotfiles...
  Installing configuration templates...
  Configuring redmine...
  Configuring redmine::database...
  Configuring redmine::unicorn...
  Configuring redmine::secret_token...
  Configuring redmine::max_concurrent_ajax_uploads...
  Configuring redmine::sudo_mode...
  Configuring redmine::autologin_cookie...
  Configuring redmine::backups...
  Configuring nginx...
  Configuring nginx::redmine...
  Installing plugins...
  Installing themes...
  2018-04-25 11:54:44,531 CRIT Supervisor running as root (no user in config file)
  2018-04-25 11:54:44,531 WARN Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
  2018-04-25 11:54:44,531 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  2018-04-25 11:54:44,531 WARN Included extra file "/etc/supervisor/conf.d/unicorn.conf" during parsing
  2018-04-25 11:54:44,561 INFO RPC interface 'supervisor' initialized
  2018-04-25 11:54:44,562 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  2018-04-25 11:54:44,562 INFO supervisord started with pid 1
  2018-04-25 11:54:45,564 INFO spawned: 'unicorn' with pid 226
  2018-04-25 11:54:45,566 INFO spawned: 'cron' with pid 227
  2018-04-25 11:54:45,568 INFO spawned: 'nginx' with pid 228
  2018-04-25 11:54:47,033 INFO success: unicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  2018-04-25 11:54:47,034 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  2018-04-25 11:54:47,034 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  2018-04-26 17:20:47,139 WARN received SIGTERM indicating exit request
  2018-04-26 17:20:47,150 INFO waiting for cron, nginx, unicorn to die
  2018-04-26 17:20:47,184 INFO stopped: nginx (exit status 0)
  2018-04-26 17:20:47,186 INFO stopped: cron (terminated by SIGTERM)
  2018-04-26 17:20:50,190 INFO waiting for unicorn to die
  2018-04-26 17:20:51,416 INFO stopped: unicorn (exit status 0)
  Initializing logdir...
  Initializing datadir...
  Symlinking dotfiles...
  Installing configuration templates...
  Configuring redmine...
  Configuring redmine::database.
  Configuring redmine::unicorn...
  Configuring redmine::secret_token...
  Configuring redmine::max_concurrent_ajax_uploads...
  Configuring redmine::sudo_mode...
  Configuring redmine::autologin_cookie...
  Configuring redmine::backups...
  Configuring nginx...
  Configuring nginx::redmine...
  Installing plugins...
  Installing themes...
  2018-04-26 17:20:54,085 CRIT Supervisor running as root (no user in config file)
  2018-04-26 17:20:54,086 WARN Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
  2018-04-26 17:20:54,086 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
  2018-04-26 17:20:54,086 WARN Included extra file "/etc/supervisor/conf.d/unicorn.conf" during parsing
  2018-04-26 17:20:54,120 INFO RPC interface 'supervisor' initialized
  2018-04-26 17:20:54,120 CRIT Server 'unix_http_server' running without any HTTP authentication checking
  2018-04-26 17:20:54,120 INFO supervisord started with pid 1
  2018-04-26 17:20:55,123 INFO spawned: 'unicorn' with pid 220
  2018-04-26 17:20:55,124 INFO spawned: 'cron' with pid 221
  2018-04-26 17:20:55,126 INFO spawned: 'nginx' with pid 222
  2018-04-26 17:20:56,639 INFO success: unicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  2018-04-26 17:20:56,639 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  2018-04-26 17:20:56,639 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

あれ?

自分で打ったコマンドはログに残ってない???

 LANG:console
 $ docker exec bklan_redmine_1 ls -l plugins
  total 8
  -rw-r--r--  1 redmine redmine   31 Jan  9 04:38 README
  drwxr-xr-x 13 root    root    4096 Apr 26 17:13 redmine_issue_templates

時刻的には 11:54 と 17:20 との間なのだけれど・・・

ログはどこにどう保存されている?

https://qiita.com/tily/items/adb433505da6c7812725

 LANG:console
 $ docker info | grep Log
  Logging Driver: json-file
   Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
  WARNING: No memory limit support
  WARNING: No swap limit support
  WARNING: No kernel memory limit support
  WARNING: No oom kill disable support
  WARNING: No cpu cfs quota support
  WARNING: No cpu cfs period support
 $ docker inspect bklan_redmine_1 | grep LogPath
        "LogPath": "/var/lib/docker/containers/285be0a6f5bf7ca6abcf73d510928fa24cb0f1414458b5bb7c807c6837148ab1/285be0a6f5bf7ca6abcf73d510928fa24cb0f1414458b5bb7c807c6837148ab1-json.log",
 $ sudo cat /var/lib/docker/containers/285be0a6f5bf7ca6abcf73d510928fa24cb0f1414458b5bb7c807c6837148ab1/285be0a6f5bf7ca6abcf73d510928fa24cb0f1414458b5bb7c807c6837148ab1-json.log
  {"log":"Initializing logdir...\n","stream":"stdout","time":"2018-04-25T02:54:40.669965042Z"}
  {"log":"Initializing datadir...\n","stream":"stdout","time":"2018-04-25T02:54:40.683753877Z"}
  {"log":"Symlinking dotfiles...\n","stream":"stdout","time":"2018-04-25T02:54:40.8159868Z"}
  {"log":"Installing configuration templates...\n","stream":"stdout","time":"2018-04-25T02:54:40.840172496Z"}
  {"log":"Configuring redmine...\n","stream":"stdout","time":"2018-04-25T02:54:40.852930473Z"}
  {"log":"Configuring redmine::database...\n","stream":"stdout","time":"2018-04-25T02:54:43.897309785Z"}
  {"log":"Configuring redmine::unicorn...\n","stream":"stdout","time":"2018-04-25T02:54:43.926696114Z"}
  {"log":"Configuring redmine::secret_token...\n","stream":"stdout","time":"2018-04-25T02:54:43.955036714Z"}
  {"log":"Configuring redmine::max_concurrent_ajax_uploads...\n","stream":"stdout","time":"2018-04-25T02:54:43.967426911Z"}
  {"log":"Configuring redmine::sudo_mode...\n","stream":"stdout","time":"2018-04-25T02:54:43.980771831Z"}
  {"log":"Configuring redmine::autologin_cookie...\n","stream":"stdout","time":"2018-04-25T02:54:43.996212052Z"}
  {"log":"Configuring redmine::backups...\n","stream":"stdout","time":"2018-04-25T02:54:44.016879438Z"}
  {"log":"Configuring nginx...\n","stream":"stdout","time":"2018-04-25T02:54:44.033014852Z"}
  {"log":"Configuring nginx::redmine...\n","stream":"stdout","time":"2018-04-25T02:54:44.034918647Z"}
  {"log":"Installing plugins...\n","stream":"stdout","time":"2018-04-25T02:54:44.345370055Z"}
  {"log":"Installing themes...\n","stream":"stdout","time":"2018-04-25T02:54:44.392061213Z"}
  {"log":"2018-04-25 11:54:44,531 CRIT Supervisor running as root (no user in config file)\n","stream":"stdout","time":"2018-04-25T02:54:44.531770749Z"}
  {"log":"2018-04-25 11:54:44,531 WARN Included extra file \"/etc/supervisor/conf.d/nginx.conf\" during parsing\n","stream":"stdout","time":"2018-04-25T02:54:44.531800222Z"}
  {"log":"2018-04-25 11:54:44,531 WARN Included extra file \"/etc/supervisor/conf.d/cron.conf\" during parsing\n","stream":"stdout","time":"2018-04-25T02:54:44.531871949Z"}
  {"log":"2018-04-25 11:54:44,531 WARN Included extra file \"/etc/supervisor/conf.d/unicorn.conf\" during parsing\n","stream":"stdout","time":"2018-04-25T02:54:44.531884241Z"}
  {"log":"2018-04-25 11:54:44,561 INFO RPC interface 'supervisor' initialized\n","stream":"stdout","time":"2018-04-25T02:54:44.562057115Z"}
  {"log":"2018-04-25 11:54:44,562 CRIT Server 'unix_http_server' running without any HTTP authentication checking\n","stream":"stdout","time":"2018-04-25T02:54:44.562140575Z"}
  {"log":"2018-04-25 11:54:44,562 INFO supervisord started with pid 1\n","stream":"stdout","time":"2018-04-25T02:54:44.562318181Z"}
  {"log":"2018-04-25 11:54:45,564 INFO spawned: 'unicorn' with pid 226\n","stream":"stdout","time":"2018-04-25T02:54:45.566891232Z"}
  {"log":"2018-04-25 11:54:45,566 INFO spawned: 'cron' with pid 227\n","stream":"stdout","time":"2018-04-25T02:54:45.566919029Z"}
  {"log":"2018-04-25 11:54:45,568 INFO spawned: 'nginx' with pid 228\n","stream":"stdout","time":"2018-04-25T02:54:45.568444494Z"}
  {"log":"2018-04-25 11:54:47,033 INFO success: unicorn entered RUNNING state, process has stayed up for \u003e than 1 seconds (startsecs)\n","stream":"stdout","time":"2018-04-25T02:54:47.033996562Z"}
  {"log":"2018-04-25 11:54:47,034 INFO success: cron entered RUNNING state, process has stayed up for \u003e than 1 seconds (startsecs)\n","stream":"stdout","time":"2018-04-25T02:54:47.034113196Z"}
  {"log":"2018-04-25 11:54:47,034 INFO success: nginx entered RUNNING state, process has stayed up for \u003e than 1 seconds (startsecs)\n","stream":"stdout","time":"2018-04-25T02:54:47.034208459Z"}
  {"log":"2018-04-26 17:20:47,139 WARN received SIGTERM indicating exit request\n","stream":"stdout","time":"2018-04-26T08:20:47.144340193Z"}
  {"log":"2018-04-26 17:20:47,150 INFO waiting for cron, nginx, unicorn to die\n","stream":"stdout","time":"2018-04-26T08:20:47.150586828Z"}
  {"log":"2018-04-26 17:20:47,184 INFO stopped: nginx (exit status 0)\n","stream":"stdout","time":"2018-04-26T08:20:47.185226634Z"}
  {"log":"2018-04-26 17:20:47,186 INFO stopped: cron (terminated by SIGTERM)\n","stream":"stdout","time":"2018-04-26T08:20:47.1862901Z"}
  {"log":"2018-04-26 17:20:50,190 INFO waiting for unicorn to die\n","stream":"stdout","time":"2018-04-26T08:20:50.190692043Z"}
  {"log":"2018-04-26 17:20:51,416 INFO stopped: unicorn (exit status 0)\n","stream":"stdout","time":"2018-04-26T08:20:51.416801769Z"}
  {"log":"Initializing logdir...\n","stream":"stdout","time":"2018-04-26T08:20:52.302093186Z"}
  {"log":"Initializing datadir...\n","stream":"stdout","time":"2018-04-26T08:20:52.316605695Z"}
  {"log":"Symlinking dotfiles...\n","stream":"stdout","time":"2018-04-26T08:20:52.55894422Z"}
  {"log":"Installing configuration templates...\n","stream":"stdout","time":"2018-04-26T08:20:52.603558203Z"}
  {"log":"Configuring redmine...\n","stream":"stdout","time":"2018-04-26T08:20:52.619022439Z"}
  {"log":"Configuring redmine::database.\n","stream":"stdout","time":"2018-04-26T08:20:53.660223208Z"}
  {"log":"Configuring redmine::unicorn...\n","stream":"stdout","time":"2018-04-26T08:20:53.689481008Z"}
  {"log":"Configuring redmine::secret_token...\n","stream":"stdout","time":"2018-04-26T08:20:53.717499341Z"}
  {"log":"Configuring redmine::max_concurrent_ajax_uploads...\n","stream":"stdout","time":"2018-04-26T08:20:53.729841755Z"}
  {"log":"Configuring redmine::sudo_mode...\n","stream":"stdout","time":"2018-04-26T08:20:53.743083789Z"}
  {"log":"Configuring redmine::autologin_cookie...\n","stream":"stdout","time":"2018-04-26T08:20:53.758485511Z"}
  {"log":"Configuring redmine::backups...\n","stream":"stdout","time":"2018-04-26T08:20:53.779061466Z"}
  {"log":"Configuring nginx...\n","stream":"stdout","time":"2018-04-26T08:20:53.795562205Z"}
  {"log":"Configuring nginx::redmine...\n","stream":"stdout","time":"2018-04-26T08:20:53.797546173Z"}
  {"log":"Installing plugins...\n","stream":"stdout","time":"2018-04-26T08:20:53.847613396Z"}
  {"log":"Installing themes...\n","stream":"stdout","time":"2018-04-26T08:20:53.900312092Z"}
  {"log":"2018-04-26 17:20:54,085 CRIT Supervisor running as root (no user in config file)\n","stream":"stdout","time":"2018-04-26T08:20:54.086123178Z"}
  {"log":"2018-04-26 17:20:54,086 WARN Included extra file \"/etc/supervisor/conf.d/nginx.conf\" during parsing\n","stream":"stdout","time":"2018-04-26T08:20:54.086154885Z"}
  {"log":"2018-04-26 17:20:54,086 WARN Included extra file \"/etc/supervisor/conf.d/cron.conf\" during parsing\n","stream":"stdout","time":"2018-04-26T08:20:54.08621893Z"}
  {"log":"2018-04-26 17:20:54,086 WARN Included extra file \"/etc/supervisor/conf.d/unicorn.conf\" during parsing\n","stream":"stdout","time":"2018-04-26T08:20:54.086231501Z"}
  {"log":"2018-04-26 17:20:54,120 INFO RPC interface 'supervisor' initialized\n","stream":"stdout","time":"2018-04-26T08:20:54.120341001Z"}
  {"log":"2018-04-26 17:20:54,120 CRIT Server 'unix_http_server' running without any HTTP authentication checking\n","stream":"stdout","time":"2018-04-26T08:20:54.120442829Z"}
  {"log":"2018-04-26 17:20:54,120 INFO supervisord started with pid 1\n","stream":"stdout","time":"2018-04-26T08:20:54.120689018Z"}
  {"log":"2018-04-26 17:20:55,123 INFO spawned: 'unicorn' with pid 220\n","stream":"stdout","time":"2018-04-26T08:20:55.125563813Z"}
  {"log":"2018-04-26 17:20:55,124 INFO spawned: 'cron' with pid 221\n","stream":"stdout","time":"2018-04-26T08:20:55.125597336Z"}
  {"log":"2018-04-26 17:20:55,126 INFO spawned: 'nginx' with pid 222\n","stream":"stdout","time":"2018-04-26T08:20:55.126564775Z"}
  {"log":"2018-04-26 17:20:56,639 INFO success: unicorn entered RUNNING state, process has stayed up for \u003e than 1 seconds (startsecs)\n","stream":"stdout","time":"2018-04-26T08:20:56.639592517Z"}
  {"log":"2018-04-26 17:20:56,639 INFO success: cron entered RUNNING state, process has stayed up for \u003e than 1 seconds (startsecs)\n","stream":"stdout","time":"2018-04-26T08:20:56.639702028Z"}
  {"log":"2018-04-26 17:20:56,639 INFO success: nginx entered RUNNING state, process has stayed up for \u003e than 1 seconds (startsecs)\n","stream":"stdout","time":"2018-04-26T08:20:56.639783323Z"}

ふむ。これ以上の情報は残ってないと。。。

O'Reilly の Docker 本の冒頭ではコマンドログも残るような書き方がしてあったのだけれど、
他の情報を見ていると、どうやら stdout と stderr だけがログに残るみたい。

入力したコマンドが残っていれば後から dockerfile を作るときに便利だと思うのだけれど・・・

* set -x しておく? [#wf051216]

シェルコンソールから set -x しておくと、打ち込んだコマンドが標準エラー出力へ印字されるようになる。

 LANG:console
 $ set -x
 $ ls
  + ls -F --color
  docker-compose.yml
 $ set +x
  + set +x
 $ ls
  docker-compose.yml

そこで、例えば docker コンテナの .bashrc に set +x しておくと logs 
にコマンドを残せるのだけれど・・・

やってみるとオートコンプリートなんかのシェルマクロも全部標準出力に出てきて非常に作業しづらい。

うーむ、一長一短な感じ。

* 他のプラグインも入れる [#vd5edfcc]

- redmine_wiki_extensions

 LANG:console
 $ docker exec -it bklan_redmine_1 bash
 # cd plugins/
 # git clone https://github.com/haru/redmine_wiki_extensions.git
 # cd redmine_wiki_extensions
 # git tag | tail
  redmine_wiki_extensions-0.1.5
  redmine_wiki_extensions-0.1.5.1
  redmine_wiki_extensions-0.2.0
  redmine_wiki_extensions-0.2.1
  redmine_wiki_extensions-0.2.2
  redmine_wiki_extensions-0.2.4
  redmine_wiki_extensions-0.2.5
  redmine_wiki_extensions-0.2.5.1
  redmine_wiki_extensions-0.3.0
  redmine_wiki_extensions-0.3.1
 # git checkout redmine_wiki_extensions-0.3.1
  Note: checking out 'redmine_wiki_extensions-0.3.1'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
  
    git checkout -b <new-branch-name>
  
  HEAD is now at 9dc86e6... fixes #655 recent macro returns wrong page name.
 # cd ..
 # git clone https://github.com/martin-denizet/redmine_custom_css
 # git clone https://github.com/martin-denizet/redmine_custom_css.git
  Cloning into 'redmine_custom_css'...
  remote: Counting objects: 148, done.
  remote: Total 148 (delta 0), reused 0 (delta 0), pack-reused 148
  Receiving objects: 100% (148/148), 236.48 KiB | 508.00 KiB/s, done.
  Resolving deltas: 100% (55/55), done.
 # cd redmine_custom_css/
 # git tag | tail -5
  0.1.3
  0.1.4
  0.1.5
  0.1.6
  0.1.7
 # git checkout 0.1.7
  Note: checking out '0.1.7'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
  
      git checkout -b <new-branch-name>
    
  HEAD is now at 506619a... Merge branch 'release/0.1.7'. Publish 0.1.7, fixes 3.4.x compatibility. Thanks @virtualmarc
  # git clone https://github.com/martin-denizet/redmine_custom_css.git
  Cloning into 'redmine_custom_css'...
  remote: Counting objects: 148, done.
  remote: Total 148 (delta 0), reused 0 (delta 0), pack-reused 148
  Receiving objects: 100% (148/148), 236.48 KiB | 508.00 KiB/s, done.
  Resolving deltas: 100% (55/55), done.
 # cd redmine_custom_css/
 # git tag | tail -5
  0.1.3
  0.1.4
  0.1.5
  0.1.6
  0.1.7
 # git checkout 0.1.7
  Note: checking out '0.1.7'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
  
    git checkout -b <new-branch-name>
  
  HEAD is now at 506619a... Merge branch 'release/0.1.7'. Publish 0.1.7, fixes 3.4.x compatibility. Thanks @virtualmarc
 # cd ..
 # git clone https://github.com/suer/redmine_absolute_dates
  Cloning into 'redmine_absolute_dates'...
  remote: Counting objects: 78, done.
  remote: Total 78 (delta 0), reused 0 (delta 0), pack-reused 78
  Unpacking objects: 100% (78/78), done.
 # cd redmine_absolute_dates/
 # git tag | tail -5
  0.0.2
  0.0.3
  for-redmine-1.2
  for-redmine-2.0
 # git checkout 0.0.3
  Note: checking out '0.0.3'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
  
    git checkout -b <new-branch-name>
  
  HEAD is now at 0e414fe... Bumped: 0.0.3
 # cd ..
 # git clone https://github.com/bdemirkir/sidebar_hide
  Cloning into 'sidebar_hide'...
  remote: Counting objects: 251, done.
  remote: Total 251 (delta 0), reused 0 (delta 0), pack-reused 251
  Receiving objects: 100% (251/251), 101.29 KiB | 434.00 KiB/s, done.
  Resolving deltas: 100% (89/89), done.
 # cd sidebar_hide/
 # git tag | tail -5
  0.0.4
  0.0.5
  0.0.6
  0.0.7
  0.0.8
 # git checkout 0.0.8
  Note: checking out '0.0.8'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
  
    git checkout -b <new-branch-name>
  
  HEAD is now at 5edf9fa... Bump the version
 # git clone https://github.com/peclik/clipboard_image_paste.git
  Cloning into 'clipboard_image_paste'...
  remote: Counting objects: 456, done.
  remote: Total 456 (delta 0), reused 0 (delta 0), pack-reused 456
  Receiving objects: 100% (456/456), 265.76 KiB | 770.00 KiB/s, done.
  Resolving deltas: 100% (168/168), done.
 # cd clipboard_image_paste/
 # git tag | tail -5
  v1.5
  v1.6
  v1.7
  v1.8
  v1.9
 # git checkout v1.9
  Note: checking out 'v1.9'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
  
    git checkout -b <new-branch-name>
  
  HEAD is now at 761bf2c... releasing v 1.9
  # cd ..
 # git clone https://github.com/tkusukawa/redmine_wiki_lists.git
  Cloning into 'redmine_wiki_lists'...
  remote: Counting objects: 385, done.
  remote: Total 385 (delta 0), reused 0 (delta 0), pack-reused 385
  Receiving objects: 100% (385/385), 101.85 KiB | 861.00 KiB/s, done.
  Resolving deltas: 100% (212/212), done.
 # cd redmine_wiki_lists/
 # git tag | tail -5
  0.0.4
  0.0.6
  0.0.7
  0.0.8
  0.0.9
 # git checkout 0.0.9
  Note: checking out '0.0.9'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
  
    git checkout -b <new-branch-name>
  
  HEAD is now at 4f8a726... Version 0.0.9
 # cd ..
 # git clone https://github.com/gatATAC/redmine_startpage
  Cloning into 'redmine_startpage'...
  remote: Counting objects: 109, done.
  remote: Total 109 (delta 0), reused 0 (delta 0), pack-reused 109
  Receiving objects: 100% (109/109), 15.52 KiB | 3.88 MiB/s, done.
  Resolving deltas: 100% (28/28), done.
 # git clone https://github.com/Restream/redmine_issue_checklist.git
  Cloning into 'redmine_issue_checklist'...
  remote: Counting objects: 251, done.
  remote: Total 251 (delta 0), reused 0 (delta 0), pack-reused 251
  Receiving objects: 100% (251/251), 387.03 KiB | 760.00 KiB/s, done.
  Resolving deltas: 100% (82/82), done.
 # cd ..
 # bundle exec rake redmine:plugins:migrate RAILS_ENV=production
  rake aborted!
  LoadError: cannot load such file -- redcloth3
  /home/redmine/redmine/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
  /home/redmine/redmine/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
  /home/redmine/redmine/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
  /home/redmine/redmine/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
  /home/redmine/redmine/plugins/redmine_wiki_extensions/init.rb:22:in `<top (required)>'
  ...
 # ## https://istb16.wordpress.com/2017/07/19/redmine-4-3-2%E3%81%AB%E3%82%A2%E3%83%83%E3%83%97%E3%83%87%E3%83%BC%E3%83%88%E3%81%A7-loaderror-redcloth3-%E3%82%A8%E3%83%A9%E3%83%BC/
 # ## によると、最新版にしなくちゃならないのかも。
 # cd plugins/redmine_wiki_extensions
 # git checkout master
  Previous HEAD position was 9dc86e6... fixes #655 recent macro returns wrong page name.
  Branch 'master' set up to track remote branch 'master' from 'origin'.
  Switched to a new branch 'master'
 # cd ../..
 # bundle exec rake redmine:plugins:migrate RAILS_ENV=production
  rake aborted!
  NameError: uninitialized constant KbArticle
  /home/redmine/redmine/plugins/clipboard_image_paste/lib/clipboard_image_paste/attachment_patch.rb:130:in `<top (required)>'
  /home/redmine/redmine/plugins/clipboard_image_paste/init.rb:33:in `block in <top (required)>'
 # cd plugins/clipboard_image_paste/
 # git checkout master
  Previous HEAD position was 761bf2c... releasing v 1.9
  Switched to branch 'master'
  Your branch is up to date with 'origin/master'.
 # cd ../..
 # bundle exec rake redmine:plugins:migrate RAILS_ENV=production
 # ## うまく行った
 # cd plugin
 # for dir in `ls -F | grep /`; do cd $dir; echo "==== $dir"; git status; cd ..; done
  ==== clipboard_image_paste/
  On branch master
  Your branch is up to date with 'origin/master'.
  
  nothing to commit, working tree clean
  ==== redmine_absolute_dates/
  HEAD detached at 0.0.3
  nothing to commit, working tree clean
  ==== redmine_custom_css/
  HEAD detached at 0.1.7
  nothing to commit, working tree clean
  ==== redmine_issue_checklist/
  On branch master
  Your branch is up to date with 'origin/master'.
  
  nothing to commit, working tree clean
  ==== redmine_issue_templates/
  HEAD detached at 0.1.9
  nothing to commit, working tree clean
  ==== redmine_startpage/
  On branch master
  Your branch is up to date with 'origin/master'.
  
  nothing to commit, working tree clean
  ==== redmine_wiki_extensions/
  On branch master
  Your branch is up to date with 'origin/master'.
  
  nothing to commit, working tree clean
  ==== redmine_wiki_lists/
  HEAD detached at 0.0.9
  nothing to commit, working tree clean
  ==== sidebar_hide/
  HEAD detached at 0.0.8
  nothing to commit, working tree clean
 # exit
 $ docker-compose restart
  Restarting bklan_redmine_1    ... done
  Restarting bklan_postgresql_1 ... done

これでうまく行った。

** redmine_startpage の設定 [#cec61212]

トップへのアクセスを /projects/bklan へ飛ばしたい。

プラグインの「設定」から、~
http://localhost:10083/settings/plugin/redmine_startpage で設定。

&ref(redmine_startpage-settings.png,,50%);

あれ?

&ref(redmine_startpage-error.png,border,50%);

 LANG:console
 $ docker exec -it bklan_redmine_1 bash
 # bundle exec rake routes | grep /projects/:id\(.:format\)
   project GET                /projects/:id(.:format)       projects#show
           PATCH              /projects/:id(.:format)       projects#update
           PUT                /projects/:id(.:format)       projects#update
           DELETE             /projects/:id(.:format)       projects#destroy
 # exit
 $

ああ、そういうことか。

&ref(redmine_startpage-settings2.png,,50%);

これで、http://localhost:10083/ へのアクセスが http://localhost:10083/projects/bklan 
へ飛ばされるようになった。

** WikiExtention の設定 [#c83e49c1]

プロジェクトの「設定」-「モジュール」で enable にする。~
http://localhost:10083/projects/bklan/settings/modules 

プロジェクトの「設定」に「WikiExtention」のタブが現れる。~
http://dora.bk.tsukuba.ac.jp:10083/projects/bklan/settings/wiki_extensions

「プロジェクトメニューにタブを追加」にて、任意の Wiki ページへ飛ばすタブを作れる。

* dockerfile について [#me2a79e1]

- Dockerfileはなぜ複雑になるのか~
https://qiita.com/port-development/items/8ab04aee45dc7f5f96ab ~
~


* Redmine について [#h0c6d72a]

-Redmine.JP~
http://redmine.jp/overview/ ~
~
-Redmine入門 - Wiki 、ニュース、文書、ファイル、フォーラムの用途 ~
http://yohshiy.blog.fc2.com/blog-entry-92.html ~
~
-モバイルアプリ~
http://redminepm.jp/ ~
~
-Redmineの気がつきにくい機能~
http://blog.redmine.jp/articles/unnoticed-features/ ~
--チケット一覧でのコンテキストメニュー
--チケットの一括編集
--チケットのトラッカー・題名・説明の変更
--特定の番号のチケットを表示
--デフォルトの検索対象は現在表示中のモジュール
--検索ボックス左の「検索」をクリックすると詳細検索画面を表示~
~
-farend fancy テーマ = 日本語が見やすいとのこと~
http://redmine.jp/glossary/t/theme/get-themes/ ~
~
-Redmineプラグインのお試し環境を立てる (docker-compose & SQLite3)~
https://qiita.com/akiko-pusu/items/c2d26672923b9d616536 ~
~
-r-labs » Wiki Extensions~
https://www.r-labs.org/projects/wikiext ~
~
-情シスへの申請・問い合わせ管理を Redmine で効率化する~
https://blog.ismg.kdl.co.jp/operation-control/redmine-operation ~
~
-決めておいた方が良いRedmine運用ルール~
https://qiita.com/y_hokkey/items/3267f7f9b1ced05e0cc0 ~
~
-Redmineでチケットのテンプレートを設定する~
https://codelab.website/redmine-issue-templates-plugin/ ~
~
-Redmineのチケットにチェックリストを追加する ~
https://codelab.website/redmine-checklist-plugin/ ~
~
-Redmineのプラグインでチケットの日付の表示形式を変更する~
https://codelab.website/redmine-absolute-dates-plugin/ ~
~
-プラグイン
-- View Customize - https://qiita.com/y_hokkey/items/7c02a3af319b353136d5#view-customize
-- Userbility = https://qiita.com/y_hokkey/items/7c02a3af319b353136d5#userbility
- デザインの格好良いテーマ
-- https://qiita.com/y_hokkey/items/7c02a3af319b353136d5#%E3%83%87%E3%82%B6%E3%82%A4%E3%83%B3%E3%81%AE%E6%A0%BC%E5%A5%BD%E8%89%AF%E3%81%84%E3%83%86%E3%83%BC%E3%83%9E ~
~
-Redmineにプラグインを入れる~
http://www.torutk.com/projects/swe/wiki/Redmine%E3%81%AB%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%82%92%E5%85%A5%E3%82%8C%E3%82%8B ~
~

* その他やりたいこと [#f31e6def]

- LDAP 認証

* ちょっと脱線 [#adabba93]

nginx の簡単な動かし方~
https://github.com/nginxinc/docker-nginx/tree/590f9ba27d6d11da346440682891bee6694245f5/mainline/alpine

 LANG:console
 $ mkdir docker-nginx
 $ mkdir html
 $ jed default.conf
 $ jed html/index.html
 $ docker run -p 10080:80 \
              -v `pwd`/default.conf:/etc/nginx/conf.d/default.conf \
              -v `pwd`/html:/usr/share/nginx/html \
              -d -rm \
              nginx:mainline-alpine

これで動かせた。

nginx:mainline-alpine は 18M しかない非常に小さなイメージだ。

* コメント・質問 [#c57c65f7]

#article_kcaptcha


Counter: 23147 (from 2010/06/03), today: 4, yesterday: 3