---
title: Cloud FoundryのコンテナランタイムをOCI標準のrunCに変更する
tags: ["BOSH", "Diego", "Docker", "Cloud Foundry", "runC"]
categories: ["Dev", "PaaS", "CloudFoundry"]
date: 2016-09-23T15:34:39Z
updated: 2016-09-23T15:35:45Z
---

[AWSにCloud Foundryをインストール](https://blog.ik.am/entries/392)しました。Cloud Foundryは[Garden](https://www.cloudfoundry.org/cloud-foundry-containers-difference-warden-docker-garden/)によってコンテナが管理されますが、
GardenはプラガブルなAPIでバックエンドを変更することができます。

* Garden Linux
* Garden Windows
* Garden runC

の3つの実装があります。今は前世代Cloud Foundryで使用されている独自実装なWarden由来のGarden Linuxがデフォルトで使われていますが、
OCI(Open Container Initiative)で策定された標準の[runC](https://runc.io/)(Dockerで使われているものと同じもの)を代わりに使うこともできます。(ちなみにGarden Windowsを使うとWindowsアプリを乗せられる)

変更は簡単で、Cloud Foundryのマニフェストの`garden-linux`を`garden-runc`に置換するだけ。


``` yaml
releases:
- {name: cf, version: latest}
- {name: diego, version: latest}
- {name: etcd, version: latest}
- {name: garden-runc, version: latest} # <- garden-linuxから変更
- {name: cflinuxfs2-rootfs , version: latest}
```

と


``` yaml
- name: diego_cell_z1
  instances: 1
  resource_pool: diego_cell_z1
  templates:
  - name: consul_agent
    release: cf
  - name: rep
    release: diego
  - name: garden
    release: garden-runc # <- garden-linuxから変更
  - name: cflinuxfs2-rootfs-setup
    release: cflinuxfs2-rootfs
  - name: metron_agent
    release: cf
```

の2箇所を変更して、


``` console
bosh upload release https://bosh.io/d/github.com/cloudfoundry/garden-runc-release?v=0.8.0
bosh -n deploy
```

でOK。

![image](https://qiita-image-store.s3.amazonaws.com/0/1852/a474e3eb-e303-c8cf-d131-7b39c5ea385a.png)

Cellが3つあればCanary Deployできるはず。コンテナ上のアプリは特に問題なく動いています。

多分近いうちにこっちがデフォルトになると思います。[Pivotal Web Services](https://run.pivotal.io/)では既に[ProductionでrunCが使われています](https://blog.pivotal.io/pivotal-cloud-foundry/products/how-cloud-foundry-gives-developers-a-reliable-container-runtime)。

1年前の記事ですが、runCにするメリットについては[こちら](https://www.cloudfoundry.org/garden-and-runc/)。
