LoginSignup
6
6

More than 5 years have passed since last update.

PackerでDocker Imageを作成してcowsayする

Last updated at Posted at 2015-09-02

PackerでDocker Imageを作成してcowsayします

前提

dockerがインストールされていること

サンプル

仕様

項目 内容
ホストOS Ubuntu 14.04 LTS
プロビジョンニング shell

コンテナにはcowsayをインストールします

json

demo.json
{
    "builders":[{
        "type": "docker",
        "image": "ubuntu:trusty",
        "export_path": "image.tar"
    }],

    "provisioners":[
    {
        "type": "shell",
        "inline": [
            "apt-get -y update",
            "apt-get install -y cowsay"
        ]
    }
    ],

    "post-processors": [{
        "type": "docker-import",
        "repository": "tbpgr/demo",
        "tag": "0.1"
    }]
}

Packer build

$ packer build demo.json

imageの確認

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
tbpgr/demo          0.1                 ec18fd15e1f0        52 seconds ago      186.7 MB
ubuntu              trusty              91e54dfb1179        12 days ago         188.4 MB

コンテナの起動

$ docker run tbpgr/demo:0.1 /usr/games/cowsay "Packer"
docker run tbpgr/demo:0.1 /usr/games/cowsay "Packer"
 _________________________
< Packer >
 -------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

外部資料

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