4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[覚書]Ottoで開発環境を構築 (MongoDBのDockerコンテナを動かす)

Last updated at Posted at 2015-12-15
  1. [覚書]Ottoで開発環境を構築
  2. [覚書]OttoでAWSに本番環境構築&デプロイ
  3. [覚書]Ottoで開発環境を構築 (Appfileをカスタマイズ → Rubyのバージョン指定)
  4. [覚書]Ottoで開発環境を構築 (MongoDBのDockerコンテナを動かす)ここ

プロジェクト作成

作業用ディレクトリを作成します。

$ mkdir -p otto-practice/examples/mongodb
$ cd otto-practice/examples/mongodb

設定

Appfileを作成します。

Dockerを使う場合は、applicationtypedocker-externalを指定し、customizationDockerの設定を記述します。

Appfile
application {
    name = "mongodb"
    type = "docker-external"
}

customization "docker" {
    image = "mongo:3.0"
    run_args = "-p 27017:27017"
}

Githubhashicorp/ottoのサンプルをそのまま使おうとするとコンパイルでエラーが発生しました。
どうやら、customization"docker"の記述が必要なようです。
Ottoの仕様を理解できていないのか、仕様が安定していないのかは未確認です。。。

コンパイル

開発環境の設定(Appfile)を読み込みます。

$ otto compile

開発環境の構築

構築

開発環境を構築します。

$ otto dev

ステータス確認

Dev environmentCREATEDになっていることを確認します。

$ otto status
==> App Info
    Application:    mongodb (docker-external)
    Project:        mongodb
    Infrastructure: aws (simple)
==> Component Status
    Dev environment: CREATED
    Infra:           NOT CREATED
    Build:           NOT BUILT
    Deploy:          NOT DEPLOYED

コンテナ確認

開発環境にアクセスして、MongoDBのコンテナが動いていることを確認します。

$ otto dev ssh
==> Executing SSH. This may take a few seconds...
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
New release '14.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:23:18 2012 from 10.0.2.2
vagrant@precise64:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
mongo               3.0                 ca3cf1f47476        10 days ago         261.6 MB
vagrant@precise64:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                      NAMES
839c09231a0e        mongo:3.0           "/entrypoint.sh mongo"   About a minute ago   Up 59 seconds       0.0.0.0:27017->27017/tcp   mongodb

原因不明のエラー

原因は不明ですが、スマホのテザリング機能を使ったネットワーク上でotto devコマンドを実行すると、下記のようなエラーが発生してしまい、Dockerのインストールに失敗してしまいました。
自宅のネットワーク上で実行した際には、問題なく実行できました。
(本件が、ネットワークに原因があるのかどうかはわかりません。。。)

==> default: Running provisioner: docker...
    default: Installing Docker (latest) onto machine...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

apt-get install -y --force-yes -q xz-utils lxc-docker -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'

Stdout from the command:

Reading package lists...
Building dependency tree...
Reading state information...
xz-utils is already the newest version.
The following extra packages will be installed:
  aufs-tools cgroup-lite git git-man liberror-perl lxc-docker-1.9.1 patch
Suggested packages:
  git-daemon-run git-daemon-sysvinit git-doc git-el git-arch git-cvs git-svn
  git-email git-gui gitk gitweb diffutils-doc
The following NEW packages will be installed:
  aufs-tools cgroup-lite git git-man liberror-perl lxc-docker lxc-docker-1.9.1
  patch
0 upgraded, 8 newly installed, 0 to remove and 181 not upgraded.
Need to get 15.4 MB of archives.
After this operation, 46.2 MB of additional disk space will be used.
Get:1 https://get.docker.com/ubuntu/ docker/main lxc-docker-1.9.1 amd64 1.9.1 [8,495 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise/universe aufs-tools amd64 1:3.0+20111101-1ubuntu1 [98.8 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ precise/main liberror-perl all 0.17-1 [23.8 kB]
Get:4 https://get.docker.com/ubuntu/ docker/main lxc-docker amd64 1.9.1 [2,094 B]
Get:5 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main git-man all 1:1.7.9.5-1ubuntu0.2 [632 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main git amd64 1:1.7.9.5-1ubuntu0.2 [6,103 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main patch amd64 2.6.1-3ubuntu0.1 [80.0 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main cgroup-lite all 1.1.5 [4,098 B]
Fetched 20.9 MB in 13s (1,561 kB/s)


Stderr from the command:

stdin: is not a tty
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/universe/a/aufs-tools/aufs-tools_3.0+20111101-1ubuntu1_amd64.deb  Size mismatch
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/libe/liberror-perl/liberror-perl_0.17-1_all.deb  Size mismatch
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/g/git/git-man_1.7.9.5-1ubuntu0.2_all.deb  Size mismatch
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Error building dev environment: Error executing Vagrant: exit status 1

The error messages from Vagrant are usually very informative.
Please read it carefully and fix any issues it mentions. If
the message isn't clear, please report this to the Otto project.

参考

以上

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?