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

更新

[[公開メモ]]

* 目次 [#sb245dfa]

#contents

* 概要 [#ac4e4f55]

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

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

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

独立した Linux 環境を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

* 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]

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

 LANG:console
 $ mkdir ~/docker-redmine    # redmine コンテナの起動設定を保存しておくフォルダ
 $ cd ~/docker-redmine
 $ 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:2.6.7
      depends_on:
      - postgresql
      environment:     # 上で設定したのと同じ DB_PASS を記入する
      - 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
 $ # パスワード等を適切に設定する
 $ sudo 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 docker-redmine_postgresql_1 ... done
  Starting docker-redmine_redmine_1    ... done
  Attaching to docker-redmine_postgresql_1, docker-redmine_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 の初期ページを確認できる。

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

#article_kcaptcha

Counter: 15875 (from 2010/06/03), today: 3, yesterday: 8