Play With Docker でDocker 版 imagebuilderを使ってみる

Play With Docker の環境を使って Docker版imagebuilderを使う方法をご紹介します。

Play With Docker とは

学習・検証を目的としたDockerのクラウド仮想環境です。
1回4時間以内という制限はありますが、Webブラウザにて操作可能で、無料で何度でも利用できます。

https://www.docker.com/play-with-docker

Play With Docker 注意点

時々不具合を起こしていたり、同時使用ユーザー上限を超えていて接続できない場合があります。
あくまで学習用環境となり、セキュリティは担保されていません。機密情報(パスワード、秘密鍵)を入力するのはお勧めしません。
作業用端末に割り当てられるディスク領域が10GなのでSDKの実行は難しいと思います。
OpenWrt imagebuilder を教材にDockerの実践的学習を行う、というスタンスで使ってみてください。

Docker IDの作成

アクセスに必要なので以下URLにてDocker IDを作成してください。

https://hub.docker.com/signup

Play With Docker へのログイン

以下URLから Play With Docker へログインしてください。
https://labs.play-with-docker.com/


インスタンス作成

ログインすると左上に利用期限の4時間のカウントダウンが始まります。
左ペインの「+ ADD NEW INSTANCE」を押下して作業用のコンソール画面を作成します。

作業用コンソールはalpine linuxで動作しており、docker がインストールされた状態です。

[node1] (local) root@192.168.0.48 ~
$ cat /etc/alpine-release 
3.10.3
[node1] (local) root@192.168.0.48 ~
$ docker --version
Docker version 19.03.4, build 9013bf583a
[node1] (local) root@192.168.0.48 ~
$ 



Imagebuilder Docker Imageを実行してOpenWrtファームウェアを作成する。

ここからは dockerでimagebuilder環境を作る方法② に記載された内容でImagebuilderのDocker Imageを実行して 目的のOpenWrtファームウェアを生成させます。

MT7621 で 19.07.1 の場合の例

Play With Docker 環境への Imagebuilder docker image の pull

$ docker pull openwrtorg/imagebuilder:ramips-mt7621-19.07.1
ramips-mt7621-19.07.1: Pulling from openwrtorg/imagebuilder
dc65f448a2e2: Pull complete 
e07688639b82: Pull complete 
0da5ae0750f1: Pull complete 
a85915736491: Pull complete 
57235cc4b494: Pull complete 
23bec15c1695: Pull complete 
Digest: sha256:f64b993f51f2ef8ce30faa8568ca33e447e05d73f7d45109e81faa0b4ea634d3
Status: Downloaded newer image for openwrtorg/imagebuilder:ramips-mt7621-19.07.1
docker.io/openwrtorg/imagebuilder:ramips-mt7621-19.07.1
[node1] (local) root@192.168.0.48 ~
$ docker images
REPOSITORY                TAG                     IMAGE ID            CREATED             SIZE
openwrtorg/imagebuilder   ramips-mt7621-19.07.1   4be5bf377027        2 weeks ago         836MB
[node1] (local) root@192.168.0.48 ~

docker run で IMAGEBUILDERコンテナを起動

$ docker run --rm -v "$(pwd)"/bin/:/home/build/openwrt/bin --name IMAGEBUILDER -it openwrtorg/imagebuilder:ramips-mt7621-19.07.1
build@a67d992612b7:~/openwrt$

IMAGEBUILDERコンテナ内でのファームウェア生成(make image)

build@a67d992612b7:~/openwrt$ sudo make image PROFILE="wsr-600" PACKAGES="kmod-mt7603 -kmod-rt2800-pci \
 -wpad-mini -iwinfo -kmod-usb-core -kmod-usb-ledtrig-usbport -kmod-usb3 -kmod-cfg80211 -hostapd-common -kmod-mac80211 \
 -kmod-mt7603 -wireless-regdb uhttpd luci"
Checking 'working-make'... ok.
Checking 'case-sensitive-fs'... ok.
Checking 'proper-umask'... ok.
Checking 'gcc'... ok.
Checking 'working-gcc'... ok.
Checking 'g++'... ok.
(中略)
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 104
Number of ids (unique uids + gids) 1
Number of uids 1
        unknown (0)
Number of gids 1
        unknown (0)
3659+1 records in
3659+1 records out
1873472 bytes (1.9 MB, 1.8 MiB) copied, 0.010368 s, 181 MB/s
3936+1 records in
3936+1 records out
2015730 bytes (2.0 MB, 1.9 MiB) copied, 0.00940265 s, 214 MB/s
padding image to 003b6000
padding image to 003b8000
padding image to 003c0000

Calculating checksums...
build@a67d992612b7:~/openwrt$ 


IMAGEBUILDERコンテナ内でのファームウェア確認

build@a67d992612b7:~/openwrt$ ls -al /home/build/openwrt/bin/targets/ramips/mt7621/
total 3852
drwxr-xr-x 2 root root     154 Feb 29 04:57 .
drwxr-xr-x 3 root root      20 Feb 29 04:56 ..
-rw-r--r-- 1 root root    3016 Feb 29 04:57 openwrt-19.07.1-ramips-mt7621-device-wsr-600.manifest
-rw-r--r-- 1 root root 3932388 Feb 29 04:57 openwrt-19.07.1-ramips-mt7621-wsr-600-squashfs-sysupgrade.bin
-rw-r--r-- 1 root root     248 Feb 29 04:57 sha256sums
build@a67d992612b7:~/openwrt$ 


IMAGEBUILDERコンテナ終了とホストAlpineLinux側での生成ファイルの確認

build@a67d992612b7:~/openwrt$ exit
exit
[node1] (local) root@192.168.0.48 ~
$ pwd
/root
[node1] (local) root@192.168.0.48 ~
$ ls -al ~/bin/targets/ramips/mt7621/
total 3852
drwxr-xr-x    2 root     root           154 Feb 29 04:57 .
drwxr-xr-x    3 root     root            20 Feb 29 04:56 ..
-rw-r--r--    1 root     root          3016 Feb 29 04:57 openwrt-19.07.1-ramips-mt7621-device-wsr-600.manifest
-rw-r--r--    1 root     root       3932388 Feb 29 04:57 openwrt-19.07.1-ramips-mt7621-wsr-600-squashfs-sysupgrade.bin
-rw-r--r--    1 root     root           248 Feb 29 04:57 sha256sums
[node1] (local) root@192.168.0.48 ~
$ 



生成したファームウェアをPlay With Docker 内からダウンロードする

Play With Docker環境では生成したファームウェアが クラウド上のApline Linux内にあるため、どうにかしてローカル環境までダウンロードしてくる必要があります。

ここではApache http Server のDocker Official Imagesを使ってHTTPでダウンロードできるようにしてみます。

apache 2.4.41 の pull

$ docker pull httpd:2.4.41-alpine
2.4.41-alpine: Pulling from library/httpd
c9b1b535fdd9: Pull complete 
8f37b2be62f6: Pull complete 
badbb502951e: Pull complete 
a27b80e2bf04: Pull complete 
2c005fed9a91: Pull complete 
Digest: sha256:ca20eca5ae5c1be31bdf99d700d86d9164edd71bcf519325bde67ed04aa1008f
Status: Downloaded newer image for httpd:2.4.41-alpine
docker.io/library/httpd:2.4.41-alpine
[node1] (local) root@192.168.0.48 ~
$ docker images
REPOSITORY                TAG                     IMAGE ID            CREATED             SIZE
openwrtorg/imagebuilder   ramips-mt7621-19.07.1   4be5bf377027        2 weeks ago         836MB
httpd                     2.4.41-alpine           cb171b88ec92        6 weeks ago         109MB
$ 

外部からの接続が可能なようにコンテナを起動する

ホストAlpine Linuxの~/bin ディレクトリをHTTPDコンテナ内のapache のDocument Rootにマップし、
かつ、httpdコンテナ内のTCPポート80番をホストOS側の8080番の待受けポートにマッピングして参照できるようにします。
(今回はコンテナ名を"APACHE"とし、dコマンドを指定してバックグラウンドで動作させています)

$ docker run -d -it --name APACHE -p 8080:80 -v "$PWD"/bin/:/usr/local/apache2/htdocs/ httpd:2.4.41-alpine
e0e69acaf8bd41f583d3f725335ed5461df9ca69980822f51abff65a592d9b04
[node1] (local) root@192.168.0.48 ~

docker ps で以下のように表示されれば正常に動作しています。

$ docker ps
CONTAINER ID        IMAGE                 COMMAND              CREATED             STATUS              PORTS                  NAMES
e0e69acaf8bd        httpd:2.4.41-alpine   "httpd-foreground"   6 seconds ago       Up 5 seconds        0.0.0.0:8080->80/tcp   APACHE
[node1] (local) root@192.168.0.48 ~
$ 


ブラウザでの参照

この状態でPlay With Docker の Web画面上部、[OPENPORT] の右側に 8080 のリンクが現れます。
(現れない場合は[OPENPORT]ボタンを押下して8080を指定してください)
クリックするとAPACHEコンテナ内で起動しているHTTPDに接続され、(コンテナ内でマップしている)ホストOSのAlpine Linuxのbinディレクトリを参照できると思います。

ディレクトリをたどって、先ほど生成したOpenWrtファームウェアをダウンロードできます。

コンテナの停止

ダウンロードが終わったらAPACHEコンテナを停止させます。

$ docker ps
CONTAINER ID        IMAGE                 COMMAND              CREATED             STATUS              PORTS                  NAMES
e0e69acaf8bd        httpd:2.4.41-alpine   "httpd-foreground"   13 minutes ago      Up 13 minutes       0.0.0.0:8080->80/tcp   APACHE
[node1] (local) root@192.168.0.48 ~
$ docker stop APACHE
APACHE
[node1] (local) root@192.168.0.48 ~
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[node1] (local) root@192.168.0.48 ~
$ 



Play With Docker の停止

4時間経過すれば自動的に削除されますが、使用後はほかの利用者のためにリソースを開放しましょう。
カウントダウンタイマーの下の[CLOSE SESSION]を押下して、Play With Docker からログアウトしてください。

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2020年03月01日 20:37