LoginSignup
33
26

More than 5 years have passed since last update.

「Re:dash」を「Docker for Mac」で動かしてみた

Last updated at Posted at 2016-09-27

「Re:dash」を「Docker for Mac」上で動かしてみた

0.はじめに

ずいぶん前に Rebuild.fm で聴いて、気になっていた「Re:dash」を試してみようと思い
mac上のDocker for Mac環境で、公式サイトの手順を参考に
Docker Composeを利用したところmac特有な部分で少しはまりましたので記事にしました。
なお、はまりどころさえ、おさえておけばdocker-composeで簡単に構築できました。

1.環境

mac OSX Yosemite
Docker for Mac ver.1.12.1-beta26.1(build: 12100)
Re:dash 0.11.1+b2095 (2016/09/26時点のlatest)

2.手順

以下Re:dash公式サイトから引用

Docker Compose
1.Make sure you have a Docker machine up and running.
2.Make sure your current working directory is the root of this GitHub repository.
3.Run docker-compose up postgres.
4.Run ./setup/docker/create_database.sh. This will access the postgres container and set up the database.
5.Run docker-compose up
6.Run docker-machine ls, take note of the ip for the Docker machine you are using, and open the web browser.
7.Visit that Docker machine IP at port 80, and you should see a Re:dash login screen.

Now proceed to “Setup”.

なのですが、後述するmac特有の問題で少しはまりましたので
以下のようにしました。※後述のワークアラウンド2で対応

Docker for Macが起動しているMacのターミナルで適当なディレクトリ上で以下のコマンドを実施します。

# 1.git clone と ディレクトリ移動
git clone https://github.com/getredash/redash.git
cd redash/

# 2.docker-compose-example.ymlより、docker-compose.ymlを作成
#   Dockerホスト上のPostgreSQLのデータ置き場を/opt/postgres-dataからカレントディレクトリ配下./postgres-dataへ変更(環境により適宜変更してください)
#   sedを使わずに `mv docker-compose-example.yml docker-compose.yml`して `vi docker-compose.yml`でもOK
#  なお、macではなく、Linuxであれば`mv docker-compose-example.yml docker-compose.yml`だけで問題と思います。
cat docker-compose-example.yml | sed -e "s/\/opt\/postgres-data/\.\/postgres-data/" > docker-compose.yml

# 3.`-d` オプション(バックグラウンド起動)をつけてPostgreSQLだけ起動
docker-compose up -d postgres

# 4.create_database.shの実行
./setup/docker/create_database.sh

# 5. 残りも`-d` オプション(バックグラウンド起動)をつけて起動
docker-compose up -d

3.セットアップ後

セットアップ後にブラウザよりhttp://127.0.0.1/へアクセス

redash_login0.png

初期の管理者ユーザー/パスワードはadmin/adminなので入力してログイン
redash_login02.png

4.mac特有のはまりどころ

Re:dashというよりも、PostgreSQLのvolumeのマウント部分でエラーがでました。

docker-compose-example.ymlの内容のままだと
PostgreSQLのDockerホスト側のvolumeが/opt/postgres-dataとなっているため、
Docker for mac の初期設定では File sharing の設定がされていないと怒られます。

redash $docker-compose up -d postgres
Pulling postgres (postgres:9.3)...
9.3: Pulling from library/postgres
6a5a5368e0c2: Pull complete
193f770cec44: Pull complete
33647077f2ee: Pull complete
53bc65f84840: Pull complete
a4d3b0f1c16a: Pull complete
bdbe3c2ddbbd: Pull complete
575bb3898603: Pull complete
72c9fe0d644d: Pull complete
b87a349fcd43: Pull complete
e7b9f48e3ddc: Pull complete
1094bf57053d: Pull complete
Digest: sha256:b33b9b7e4de09ac8ebd5f44e03b99569b48a2040463ed4ec8b841e46993359c5
Status: Downloaded newer image for postgres:9.3
Creating redash_postgres_1

ERROR: for postgres  Cannot start service postgres: Mounts denied: 
The path /opt/postgres-data
is not shared from OS X and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> File Sharing.
See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.
.
ERROR: Encountered errors while bringing up the project.

4.1.ワークアラウンドその1

PostgreSQLのホスト側のvolumeについて/opt/postgres-dataをそのまま利用する場合

エラーメッセージに記載のURLに従い、Dockerアイコン-> Preferences -> File sharingより
GUIの設定で/opt/を追加します。

また、Macのため/opt/配下はrootのパーミションエラーも出るので、
sudoにて事前に/opt/postgres-dataディレクトリ作成と
作成したディレクトリのオーナーもrootからログインユーザー(*)に変更もします。
*:以下のYOUR_LOGIN_USER_NAME部分は自分アカウントに置き換えてください)

redash $docker-compose up -d postgres
Starting redash_postgres_1

ERROR: for postgres  Cannot start service postgres: mkdir /opt/postgres-data: permission denied
ERROR: Encountered errors while bringing up the project.
redash $sudo mkdir /opt/postgres-data
Password:
redash $sudo chown YOUR_LOGIN_USER_NAME /opt/postgres-data/
redash $docker-compose up -d postgres
Starting redash_postgres_1

4.2.ワークアラウンドその2

PostgreSQLのホスト側のvolumeについて/opt/postgres-dataから変更する。
/opt/postgres-dataではなく、docker-composeを操作するユーザー(ログインユーザー)が
/users/の配下のどこか適当なディレクトリ(Docker for macでデフォルトでFile sharingの設定がされてている)おり、ディレクトリおよびファイル作成権限があるディレクトリへ置き換える。
今回は動作検証が目的なので、git cloneしたredashディレクトリ配下に変更しました、
具体的には以下のようにdocker-compose.ymlのpostgresのvolumesを変更。

docker-compose.yml
redash:
  image: redash/redash:latest
  ports:
    - "5000:5000"
  links:
    - redis
    - postgres
  environment:
    REDASH_STATIC_ASSETS_PATH: "../rd_ui/dist/"
    REDASH_LOG_LEVEL: "INFO"
    REDASH_REDIS_URL: "redis://redis:6379/0"
    REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
    REDASH_COOKIE_SECRET: veryverysecret
redis:
  image: redis:2.8
postgres:
  image: postgres:9.3
  volumes:
    - ./postgres-data:/var/lib/postgresql/data
redash-nginx:
  image: redash/nginx:latest
  ports:
    - "80:80"
  links:
    - redash

以上

33
26
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
26