LoginSignup
1
3

More than 5 years have passed since last update.

IBM Container に Vagrant からログインする設定 忘備録

Last updated at Posted at 2016-12-14

概要

Bluemix の IBM Container を作成した後、 コンテナにログインするまでの環境セットアップの忘備録です。ローカルの環境の Mac + Vagrant + BOX で、Vagrant で起動した Ubuntu 16.04 から Bluemix 上の IBM Container にログインする環境構築方法です。

自Macに仮想マシン起動

Vagrant から Ubuntu 16.04 の仮想サーバーを起動します。

$ mkdir Bluemix-Cli
$ Bluemix-Cli
$ vagrant init ubuntu/xenial64
$ vagrant up

BOXの Ubuntu 16.04 のイメージはこちらのURL https://atlas.hashicorp.com/ubuntu/boxes/xenial64 を利用しました。

CFコマンドのインストール

参考URLは、こちら https://github.com/cloudfoundry/cli です。

Ubuntu の リポジトリに CloudFoundry のリポジトルを追加します。

# sudo -s
# wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
OK

# echo "deb http://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
deb http://packages.cloudfoundry.org/debian stable main

CloudFoundry の コマンド cf-cli をインストールします。 バージョンが表示されたらインストール成功です。

# apt-get update
# apt-get install cf-cli
# cf -v
cf version 6.22.2+a95e24c-2016-10-27

Bluemix CLI のイントール

参考URLは、こちら http://clis.ng.bluemix.net/ui/home.html です。 IBMのWebサイトからダウンロードして、インストールシェルを実行します。

# wget http://public.dhe.ibm.com/cloud/bluemix/cli/bluemix-cli/Bluemix_CLI_0.4.4_amd64.tar.gz
# tar xzvf Bluemix_CLI_0.4.4_amd64.tar.gz 
# cd Bluemix_CLI/
# ./install_bluemix_cli 

以下のメッセージが表示されていれば成功です。

The Bluemix Command Line Interface (Bluemix CLI) is installed successfully.

Bluemix へのログイン

Email に Bluemix の ユーザーID、Password に ポータルにログインする時と同じパスワードを入れて認証が通ると、スペースの選択して完了です。

# bluemix login -a https://api.ng.bluemix.net
Invoking 'cf login -a https://api.ng.bluemix.net'...

API endpoint: https://api.ng.bluemix.net

Email> 

Docker コマンドのインストール

cf の IBM Container プラグインは、docker コマンドを利用しているので、先にインストールしておきます。

# apt-get install docker.io

IBM Container プラグインのインストール

参考URL https://console.ng.bluemix.net/docs/containers/container_cli_cfic.html
以下の手順でインストールします。

# cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-linux_x64

**Attention: Plugins are binaries written by potentially untrusted authors. Install and use plugins at your own risk.**

Do you want to install the plugin https://static-ice.ng.bluemix.net/ibm-containers-linux_x64? (y or n)> y

Attempting to download binary file from internet address...
10088681 bytes downloaded...
Installing plugin ibm-containers-linux_x64...
OK
Plugin IBM-Containers v0.8.964 successfully installed.

以下のコマンドで確認します。

# cf plugins
Listing Installed Plugins...
OK

Plugin Name      Version   Command Name   Command Help
IBM-Containers   0.8.964   ic             IBM Containers plug-in

IBM コンテナへのログイン

docker のコマンドを実行する前に、以下の様にログインが必要です。

# cf ic login

これで、Bluemix のポータルから起動した IBM コンテナのリストが見れる様になりました。

# cf ic ps
CONTAINER ID        IMAGE                                       COMMAND             CREATED             STATUS                PORTS                NAMES
f5348428-fa3        registry.ng.bluemix.net/ibmliberty:latest   ""                  2 hours ago         Running 2 hours ago   9080/tcp, 9443/tcp   node4
7dcd6e65-919        registry.ng.bluemix.net/ibmliberty:latest   ""                  2 hours ago         Running 2 hours ago   9080/tcp, 9443/tcp   node2

これから、それぞれのコンテナにログインしてみます。

# cf ic exec -i -t f5348428-fa3 /bin/bash
root@instance-00037616:/# 

もう一つのコンテナへログイン

# cf ic exec -i -t 7dcd6e65-919 /bin/bash
root@instance-0003727e:/# 

IBMコンテナへ ネットワークツールのインストール

初期の状態では、ifconfig などのネットワークのツールが入っていないので、追加します。

# apt-get install net-tools
# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ns184ea59e-dc0 Link encap:Ethernet  HWaddr fa:16:3e:af:db:4a  
          inet addr:172.29.0.5  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::f816:3eff:feaf:db4a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1450  Metric:1
          RX packets:13070 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10762 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:50723062 (50.7 MB)  TX bytes:590260 (590.2 KB)

以上です。

1
3
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
3