Mellanox Onyx上でDockerを動作させてみる - 1 -

概要

MLNX-OS(旧名称) 3.6.4006以降でMellanoxスイッチ上でDocker機能がサポートされています。
本稿ではSN2010でDockerを有効化させてUbuntuのコンテナを作成するところまでを記載します。

準備

Dockerのイメージをリポジトリからスイッチにダウンロードするためにインターネットへの接続性と時刻合わせが必要となります。

OSバージョンの確認

動作しているOnyxバージョンを確認します。
本機器は3.6.8160が動作しています。

SN2010 [standalone: master] # show version
Product name:      Onyx
Product release:   3.6.8160
Build ID:          #1-dev
Build date:        2018-10-12 09:13:28
Target arch:       x86_64
Target hw:         x86_64
Built by:          jenkins@4738efaf1b07
Version summary:   X86_64 3.6.8160 2018-10-12 09:13:28 x86_64

Product model:     x86onie
Host ID:           ***********
System serial num: ***********
System UUID:       ***********

Uptime:            32m 53.320s
CPU load averages: 2.11 / 2.09 / 1.91
Number of CPUs:    4
System memory:     2470 MB used / 5341 MB free / 7811 MB total
Swap:              0 MB used / 0 MB free / 0 MB total
管理用ポート

インターネットへの接続を行うためにmgmt0ポートにIPアドレスを設定します。

SN2010 [standalone: master] (config) # no interface mgmt0 dhcp
SN2010 [standalone: master] (config) # interface mgmt0 ip address 192.168.0.10 /24
SN2010 [standalone: master] (config) # show ip interface brief

----------------------------------------------------------------------------------------------------------------------------------------
Interface           Address/Mask             Primary           Admin-state         Oper-state          MTU                 VRF
----------------------------------------------------------------------------------------------------------------------------------------
mgmt0               192.168.0.10/24                            Enabled             Up                  1500                default
デフォルトゲートウェイ

デフォルトゲートウェイを設定します。

SN2010 [standalone: master] (config) # ip route vrf default 0.0.0.0/0 192.168.0.1
SN2010 [standalone: master] (config) # show ip route

Flags:
  F: Failed to install in H/W
  B: BFD protected (static route)
  i: BFD session initializing (static route)
  x: protecting BFD session failed (static route)

VRF Name default:
  --------------------------------------------------------------------------------------
  Destination     Mask            Flag   Gateway         Interface      Source   AD/M
  --------------------------------------------------------------------------------------
  default         0.0.0.0                192.168.0.1     mgmt0          static   1/1
  192.168.0.0     255.255.255.0          0.0.0.0         mgmt0          direct   0/0
DNSサーバ

NTPサーバの名前解決のためにDNSサーバを設定します。
NTPサーバをIPアドレスで指定する場合は不要です。

SN2010 [standalone: master] (config) # ip name-server 8.8.8.8
SN2010 [standalone: master] (config) # show hosts

Hostname: SN2010

Name servers:
      8.8.8.8                               configured

Domain names:
  No domain names active.

Static IPv4 host mappings:
  127.0.0.1                            --> localhost

Static IPv6 host mappings:
  ::1                                  --> localhost6

Automatically map hostname to loopback address     : yes
Automatically map hostname to IPv6 loopback address: no
NTPサーバ

NTPサーバを指定します。

SN2010 [standalone: master] (config) # ntp server ntp.nict.jp
SN2010 [standalone: master] (config) # show ntp

NTP is administratively            : enabled
NTP Authentication administratively: disabled

Clock is synchronized:
  Reference: 133.243.238.164
  Offset   : -15.633 ms

Active servers and peers:
  133.243.238.164:
    Configured as      : ntp.nict.jp
    Conf Type          : serv
    Status             : sys.peer(*)
    Stratum            : 1
    Offset(msec)       : -15.633
    Ref clock          : .NICT.
    Poll Interval (sec): 64
    Last Response (sec): 2
    Auth state         : none
タイムゾーン

タイムゾーンもJapanにしておきます。

SN2010 [standalone: master] (config) # clock timezone Asia Eastern Japan
SN2010 [standalone: master] (config) # show clock
Time:       14:02:42
Date:       2018/11/14
Time zone:  Asia Eastern Japan (Japan)
UTC offset: +0900 (UTC plus 9 hours)

Docker

Dockerの有効化
SN2010 [standalone: master] (config) # docker no shutdown
SN2010 [standalone: master] (config) # show docker
Dockers state: enabled
イメージの取得

リポジトリからDockerイメージ Ubuntuを取得します。

SN2010 [standalone: master] (config) # docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
473ede7ed136: Pull complete
c46b5fa4d940: Pull complete
93ae3df89c92: Pull complete
6b1eed27cade: Pull complete
Digest: sha256:29934af957c53004d7fb6340139880d23fb1952505a15d69a03af0d1418878cb
Status: Downloaded newer image for ubuntu:latest
SN2010 [standalone: master] (config) # show docker images
-----------------------------------------------------------------------
Image                        Version      Created            Size
-----------------------------------------------------------------------
ubuntu                       latest       3 weeks ago        85.8MB
コンテナの作成と起動
SN2010 [standalone: master] (config) # docker start ubuntu latest my-ubuntu now
Attempting to start docker container. Please wait (this can take a minute)...
SN2010 [standalone: master] (config) # show docker ps
-------------------------------------------------------------------------------------------
Container           Image:Version           Created                Status
-------------------------------------------------------------------------------------------
my-ubuntu           ubuntu:latest           14 seconds ago         Up 10 seconds
コンテナへのログイン
SN2010 [standalone: master] (config) # docker exec my-ubuntu "bin/bash"
Running exec_name:[bin/bash]

root@SN2010:/#
root@SN2010:/# uname -a
Linux SN2010 3.10.0-327.36.3.el7MELLANOXsmp-x86_64 X86_64 jenkins #1 2018-08-14 07:55:24 SMP x86_64 x86_64 x86_64 GNU/Linux
root@SN2010:/# exit
exit
SN2010 [standalone: master] (config) #