Edited at

Vagrant+Docker+figでRedmineを動かす

More than 3 years have passed since last update.

https://registry.hub.docker.com/u/sameersbn/redmine/

を参考に、Vagrant+Docker上でRedmineを動かしてみました。


実行環境

Vagrant上のCentOS7


CentOS7のboxダウンロード

vagrant cloudからダウンロード

$ vagrant box add chef/centos-7.0 --provider virtualbox

$ vagrant init chef/centos-7.0

cf) https://atlas.hashicorp.com/chef/boxes/centos-7.0


Vagrantの設定

ゲストのCentOS7の port 10080 でRedmineを動かすので以下の通り設定。

ホストから http://localhost:1234/ でアクセス出来るようになる。

$ vim Vagrantfile


Vagrantfile

# 以下の行をコメントイン

config.vm.network "forwarded_port", guest: 10080, host:1234


CentOS7を起動してログイン

$ vagrant up

$ vagrant ssh


dockerインストール

$ sudo su -

# yum update -y
# yum install docker
# yum info docker
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.riken.jp
* updates: ftp.iij.ad.jp
Installed Packages
Name : docker
Arch : x86_64
Version : 1.5.0
Release : 28.el7.centos
Size : 31 M
Repo : installed
From repo : extras
Summary : Automates deployment of containerized applications
URL : http://www.docker.com
License : ASL 2.0
Description : Docker is an open-source engine that automates the deployment of any
: application as a lightweight, portable, self-sufficient container that will
: run virtually anywhere.
:
: Docker containers can encapsulate any payload, and will run consistently on
: and between virtually any server. The same container that a developer builds
: and tests on a laptop will run at scale, in production*, on VMs, bare-metal
: servers, OpenStack clusters, public instances, or combinations of the above.

cf) https://docs.docker.com/installation/centos/#installing-docker-centos-7


dockerサービス起動

# systemctl enable docker

ln -s '/usr/lib/systemd/system/docker.service' '/etc/systemd/system/multi-user.target.wants/docker.service'
#
# systemctl start docker
#
# systemctl status docker
docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
Active: active (running) since 土 2015-04-04 07:18:34 UTC; 2h 37min ago
Docs: http://docs.docker.com
Main PID: 2944 (docker)
CGroup: /system.slice/docker.service
└─2944 /usr/bin/docker -d --selinux-enabled -H fd://


figインストール

/usr/local/bin/fig 持ってきて実行権限付与してるだけ。

# curl -L https://github.com/docker/fig/releases/download/1.0.1/fig-`uname -s`-`uname -m` > /usr/local/bin/fig; chmod +x /usr/local/bin/fig

cf) http://www.fig.sh/install.html


postgresqlコンテナ、redmineコンテナ起動

fig.yml を持ってきて、fig up実行。

ctrl+c で停止可。

# mkdir work && cd $_ 

# wget https://raw.githubusercontent.com/sameersbn/docker-redmine/master/fig.yml
# fig up

※ 初回実行時は、fig.yml に書いてある docker image がダウンロードされる。

今回は以下のイメージがダウンロードされる。

合計800MB超あるのでそれなりに時間がかかる。

sameersbn/postgresql:9.4

sameersbn/redmine:3.0.1

# docker images

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
sameersbn/redmine 3.0.1 ceafd99f6877 11 days ago 617.7 MB
sameersbn/postgresql 9.4 271ad7e099d3 8 weeks ago 232.6 MB


fig.yml

postgresql:

image: sameersbn/postgresql:9.4
environment:
- DB_USER=redmine
- DB_PASS=phatiphohsukeuwo
- DB_NAME=redmine_production
redmine:
image: sameersbn/redmine:3.0.1
links:
- postgresql:postgresql
environment:
- DB_USER=redmine
- DB_PASS=phatiphohsukeuwo
- DB_NAME=redmine_production
ports:
- "10080:80"


参考


実行ログ

Recreating workforredmine_postgresql_1...

Recreating workforredmine_redmine_1...
Attaching to workforredmine_postgresql_1, workforredmine_redmine_1
redmine_1 | Waiting for database server to accept connections
redmine_1 | 2015-04-04 08:19:48,678 CRIT Supervisor running as root (no user in config file)
redmine_1 | 2015-04-04 08:19:48,678 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
redmine_1 | 2015-04-04 08:19:48,678 WARN Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
redmine_1 | 2015-04-04 08:19:48,678 WARN Included extra file "/etc/supervisor/conf.d/unicorn.conf" during parsing
redmine_1 | 2015-04-04 08:19:48,712 INFO RPC interface 'supervisor' initialized
redmine_1 | 2015-04-04 08:19:48,712 CRIT Server 'unix_http_server' running without any HTTP authentication checking
redmine_1 | 2015-04-04 08:19:48,713 INFO supervisord started with pid 1
redmine_1 | 2015-04-04 08:19:49,715 INFO spawned: 'unicorn' with pid 83
redmine_1 | 2015-04-04 08:19:49,718 INFO spawned: 'cron' with pid 84
redmine_1 | 2015-04-04 08:19:49,719 INFO spawned: 'nginx' with pid 85
redmine_1 | 2015-04-04 08:19:50,927 INFO success: unicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
redmine_1 | 2015-04-04 08:19:50,927 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
redmine_1 | 2015-04-04 08:19:50,927 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
17774ce54fc2 sameersbn/redmine:3.0.1 "/app/init app:start 12 minutes ago Up 12 minutes 443/tcp, 0.0.0.0:10080->80/tcp workforredmine_redmine_1
20f021504bdb sameersbn/postgresql:9.4 "/start" 12 minutes ago Up 12 minutes 5432/tcp workforredmine_postgresql_1


アクセス

http://localhost:1234/ でアクセス

username: admin

password: admin


補足


docker run で実行

figを使わずに、docker run で postgresql と redmine を別々に動かしてもいけるはずですが、エラーが出たのでまだ試していません。

面倒だったら fig を使えと、以下に書いてあります。

https://github.com/sameersbn/docker-redmine/issues/68


please try using fig.

edit: or manually start the database container and link to the redmine container.



Vagrantのprivate_network設定

vagrant 1.6.3 だったので、以下の設定で

vagrant up すると、エラーが出ました


Vagrantfile

# 以下の行をコメントイン

config.vm.network :private_network, ip: "192.168.33.10"

vagrant 1.6.5 からは直っているらしいです。

Vagrantのprivate_networkをCentOS7.0で設定