3
3

More than 5 years have passed since last update.

kitchen-dockerでホストのボリュームをマウントする

Last updated at Posted at 2014-12-15

dockerコマンド

Dockerコマンドでは以下のようにホストのディレクトリをマウントすることができます。

sudo docker run -t -i -v /var/host:/var/guest:rw centos /bin/bash

これを、Kitchen-Dockerでやるにはどうするかというお話。

Kitchen-Docker

driver_configのvolumeを使う形になります。

こんな感じ。

.kitchen.yml
---
driver:
  name: docker

driver_config:
  use_sudo: false
  socket: <%= ENV['DOCKER_HOST'] %>

platforms:
  - name: centos-6.5

suites:
  - name: default
    driver_config:
      volume:
        - <%= Dir::pwd %>/host:/var/guest:rw
    run_list:
      - recipe[pz-postgresql]
    attributes:

busser:
  sudo: true

Templateエンジンが噛んでいるのでRubyのコードが埋め込めるのが素敵。
各人好きな場所にソースコードを置いてもらっても同じように動く。

ユースケース

今まで、Vagrant(VirtualBox)で複数立てるとリソース食いすぎるから、
無理やりAll in Oneで開発環境作ってたのとか、
コンポーネントごとに分けて、コンテナ同士繋いで開発環境にするのとか良いかもしれない。
Test-KitchenならChef連携を作りこまなくて良くて、
Cookbookの開発フローと実際の開発環境の構築フローが同じにできるのが楽な気がする。

3
3
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
3
3