LoginSignup
1
1

More than 5 years have passed since last update.

[VIP] MacのVB上でCoreOSをホストに使い、alpineベースのdocker環境を作る part 2

Posted at

構成

Mac上のVBにCoreOSを入れ、インストールする。

  • prat 2

CoreOSの基本設定とdockerの基本設定をする。 --> この記事

  • part 3

alpineベースのdockerを楽しむ。

CoreOSの設定である、cloud-config.ymlを作っていく

他の記事を見て下さい!!!

最終的なconfig

  • まずはcloud-config.ymlをHOMEに置く
cloud-config.yml
#cloud-config

hostname: coreos-host01

coreos:
  update:
    reboot-strategy: best-effort
  etcd:
    discovery: https://discovery.etcd.io/{HASH}
    addr: 192.168.59.101:4001
    peer-addr: 192.168.59.101:7001
    bind-addr: 0.0.0.0
  fleet:
    public_ip: 192.168.59.101
  units:
    - name: etcd.service
      command: start
    - name: fleet.service
      command: start
    - name: docker.service
      command: start
    - name: timezone.service
      command: start
      content: |
        [Unit]
        Description=timezone
        [Service]
        Type=oneshot
        RemainAfterExit=yes
        ExecStart=/usr/bin/ln -sf ../usr/share/zoneinfo/Japan /etc/localtime
    - name: 10-static.network
      runtime: no
      content: |
        [Match]
        Name=eth0

        [Network]
        Address=192.168.59.101/24
        Gateway=192.168.59.1
        DNS=8.8.8.8
        DNS=8.8.4.4

users:
  - name: coreuser
    passwd: `openssl passwd -1`で生成したパスワード
    groups:
      - sudo
      - docker
    ssh-authorized-keys:
      - ssh-rsa ***で記させる公開鍵
  • cloud-configのシンタックスチェック
# coreos-cloudinit -validate=true -from-file=./cloud-config.yml
  • 初回インストール
    • コマンド中のstableは自分がダウンロードしたバージョン{Stable | Beta | Alpha}によって書き直す
$ sudo coreos-install -d /dev/sda -C stable -c ./cloud-config.yml
…
割愛
…
gpg: key 93D2DCB4 marked as ultimately trusted
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: Good signature from "CoreOS Buildbot (Offical Builds) <buildbot@coreos.com>" [ultimate]
Installing cloud-config...
Success! CoreOS stable 835.13.0 is installed on /dev/sda
  • ここまで来たら、一旦VMを落とす
$ sudo shutdown -h now
  • VMのStorageからCoreOSを抜く

Screen Shot 2016-05-17 at 17.42.01.png

  • その後、起動。
    • VNのコンソールから入れることを確認

Screen Shot 2016-05-17 at 17.44.42.png

  • MACのCLIから、鍵でssh出来ることも確認。
$ ssh -i id_rsa-try-docker coreuser@192.168.59.100 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
Warning: Permanently added '192.168.59.100' (ED25519) to the list of known hosts.
Last login: Tue May 17 17:44:23 2016
CoreOS stable (835.13.0)
coreuser@coreos-host01 ~ $
  • 先ほどのcloud-config.ymlは以下に格納されている
PATH
/var/lib/coreos-install/user_data
  • 最後のcoreosのupdateをしておく
$ sudo update_engine_client -update

参考資料

【CoreOS】cloud-config解説〜インストール

Dockerを設定していく

  • 現状バージョンを確認(2016/05/17)
$ docker -v                   
Docker version 1.9.1, build 9894698
1
1
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
1
1