LoginSignup
5
5

More than 5 years have passed since last update.

Azureでxplat-cliを使ってdockerしてみた

Posted at

xplat-cliインストール

http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/からダウンロードしてインストール

Azureの設定

1.AzurePortalへログインする。
2.ActiveDirectoryがなければ作成する
3.ActiveDirecotryを選択し、ユーザを作成する。
4.作成後、ID(メールアドレス)と仮パスワードが発行されるのでメモっておく
5.設定メニュー→管理者をクリックし、先ほどのメールアドレスを入力して共同管理者とする
6.AzurePortalをログアウトし、共同管理者でログイン。初回ログイン時のパスワード変更を行っておく

xplat-cliを使ってみる

まずはログイン

usernameとpasswordはAzureの設定@6で設定したものです

$ azure login -u [username] -p [password] -q

info:    Executing command login
/info:    Added subscription Windows Azure MSDN - Visual Studio Ultimate
info:    Setting subscription Windows Azure MSDN - Visual Studio Ultimate as default
+
info:    login command OK

imageの一覧

後々必要になるのでimageの一覧を見ておきます。

$ azure vm image list
info:    Executing command vm image list
+ Fetching VM images
data:    Name                                                                                                                  Category  OS
data:    --------------------------------------------------------------------------------------------------------------------  --------  -------
data:    03f55de797f546a1b29d1b8d66be687a__Visual-Studio-14-Professional-CTP-14.0.21901.1-AzureSDK-2.3-WS2012R2                Public    Windows
...snip...
data:    5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS-65-20140606                                                        Public    Linux
data:    5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS-70-20140725                                                        Public    Linux
...snip...
data:    b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04-LTS-amd64-server-20140723-en-us-30GB                Public    Linux
data:    b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04-LTS-amd64-server-20140724-en-us-30GB                Public    Linux
...snip...
info:    vm image list command OK

vm docker create

こういうことだそうです。

$ azure vm docker create --helphelp:    Create a VM
help:
help:    Usage: vm docker create [options] <dns-name> <image> <user-name> [password]
help:
help:    Options:
help:      -h, --help                             output usage information
help:      -v, --verbose                          use verbose output
help:      --json                                 use json output
help:      -dp, --docker-port [port]              Port to use for docker [4243]
help:      -dc, --docker-cert-dir [dir]           Directory containing docker certs [.docker/]
help:      -c, --connect                          connect to existing VMs
help:      -l, --location <name>                  the location
help:      -a, --affinity-group <name>            the affinity group
help:      -u, --blob-url <url>                   the blob url for OS disk
help:      -z, --vm-size <size>                   the virtual machine size [small]
help:          extrasmall, small, medium, large, extralarge, a5, a6, a7
help:      -n, --vm-name <name>                   the virtual machine name
help:      -e, --ssh [port]                       the ssh port to enable [22]
help:      -t, --ssh-cert <pem-file|fingerprint>  the SSH certificate
help:      -P, --no-ssh-password                  indicates that the password should be removed when using --ssh-cert
help:      -w, --virtual-network-name <name>      the virtual network name
help:      -b, --subnet-names <list>              the comma-delimited subnet names
help:      -A, --availability-set <name>          the name of availability set to create or use
help:      -s, --subscription <id>                the subscription id
help:      -d, --custom-data <custom-data-file>   CustomData file

というわけで作ってみる

$ azure vm docker create docker-ubuntu-1404 b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04-LTS-amd64-server-20140723-en-us-30GB  azureuser 'fooBar99!'
info:    Executing command vm docker create
info:    Found docker certificates.
+ Looking up image b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04-LTS-amd64-server-20140723-en-us-30GB
+ Looking up cloud service
info:    cloud service docker-ubuntu-1404 not found.
error:   location or affinity group is required for a new cloud service
please specify --location or --affinity-group
help:    following commands show available locations and affinity groups:
help:        azure vm location list
help:        azure account affinity-group list
error:
error:   vm docker create command failed

エラーが出たのでlocationを指定します。

$ azure vm location list
info:    Executing command vm location list
+ Getting locations
data:    Name
data:    ----------------
data:    South Central US
data:    Central US
data:    East US 2
data:    East US
data:    West US
data:    North Central US
data:    North Europe
data:    West Europe
data:    East Asia
data:    Southeast Asia
data:    Japan West
data:    Japan East
data:    Brazil South
info:    vm location list command OK

Japan Eastでいきます

$ azure vm docker create -l "Japan East" docker-ubuntu-1404 b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04-LTS-amd64-server-20140723-en-us-30GB  azureuser 'fooBar99!'
info:    Executing command vm docker create
info:    Found docker certificates.
+ Looking up image b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04-LTS-amd64-server-20140723-en-us-30GB
+ Looking up cloud service
+ Creating cloud service
+ Retrieving storage accounts
+ Looking up cloud service
warn:    --location option will be ignored
+ Getting cloud service properties
+ Looking up deployment
+ Creating VM
info:    OK
info:    vm docker create command OK

できた・・・っぽい。続きはまた。

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