LoginSignup
1

More than 5 years have passed since last update.

posted at

updated at

Windows上にjulia-lang実行用のDocker環境を作る

VirtualBox, Vagrant, Container Linux を使います

概要

julia-lang のdockerイメージを動かしたいので
windows 機へ docker 実行環境を作りたい

  • VirtualBox:仮想化ソフトウェア
  • Vagrant:仮想化環境を操作するためのツール。
  • Container Linux:Docker実行用に特化した Linux. 内容は固定されていて, update は vagrant box updateで行う.以前はCoreOSという名称.

環境構築

  • windows 10 pro で環境を構築しました
  1. Downloads_Old_Builds_5.1 – Oracle VM VirtualBoxから次の二つの最新版をダウンロードし、順にインストールします
    • VirtualBox 5.1.30 platform packages
    • VirtualBox 5.1.30 Oracle VM VirtualBox Extension Pack
    • (VirtualBox 5.2.0 は windows版 vagrant 2.0.0 では対応していませんでした. 2017/10/20)
  2. Download - Vagrant by HashiCorpから最新版をダウンロードしインストールします
    • Vagrant 2.0.0 (windows 64bit版)
    • インストール後、再起動を要求されます
  3. container linux 用のディレクトリを用意
    • mkdir C:\Users\user\projects\vms
  4. container linux の Vagrantfile を 配備 (powershellでの作業)
cd C:\Users\user\projects\vms
# git を使っていれば
git clone https://github.com/coreos/coreos-vagrant 
# zip でダウンロードして展開
Invoke-WebRequest -Uri "https://github.com/coreos/coreos-vagrant/archive/master.zip" -OutFile ./coreos.zip
Expand-Archive ./coreos.zip -DestinationPath ./
# ディレクトリ移動
cd .\coreos-vagrant-master\
# ゲストOS作成
vagrant up
  • コマンド実行ログ例

2017/10/20時点のcoreosバージョンはv1562.1.0でした.
更新があればvagrant box update でアップデートできます

PS C:\Users\user\projects\vms\coreos-vagrant-master> vagrant up
Installing plugins: vagrant-ignition
Installing the 'vagrant-ignition' plugin. This can take a few minutes...
Fetching: vagrant-share-1.1.9.gem (100%)
Fetching: vagrant-ignition-0.0.3.gem (100%)
Installed the plugin 'vagrant-ignition (0.0.3)'!
Bringing machine 'core-01' up with 'virtualbox' provider...
==> core-01: Box 'coreos-alpha' could not be found. Attempting to find and install...
    core-01: Box Provider: virtualbox
    core-01: Box Version: >= 0
==> core-01: Loading metadata for box 'https://alpha.release.core-os.net/amd64-usr/current/coreos_production_vagrant_virtualbox.json'
    core-01: URL: https://alpha.release.core-os.net/amd64-usr/current/coreos_production_vagrant_virtualbox.json
==> core-01: Adding box 'coreos-alpha' (v1562.1.0) for provider: virtualbox
    core-01: Downloading: https://alpha.release.core-os.net/amd64-usr/1562.1.0/coreos_production_vagrant_virtualbox.box
    core-01: Progress: 100% (Rate: 20.8M/s, Estimated time remaining: --:--:--)
    core-01: Calculating and comparing box checksum...
==> core-01: Successfully added box 'coreos-alpha' (v1562.1.0) for 'virtualbox'!
==> core-01: Importing base box 'coreos-alpha'...
==> core-01: Configuring Ignition Config Drive
==> core-01: Matching MAC address for NAT networking...
==> core-01: Checking if box 'coreos-alpha' is up to date...
==> core-01: Setting the name of the VM: coreos-vagrant-master_core-01_1508432850002_92455
==> core-01: Clearing any previously set network interfaces...
==> core-01: Preparing network interfaces based on configuration...
    core-01: Adapter 1: nat
    core-01: Adapter 2: hostonly
==> core-01: Forwarding ports...
    core-01: 22 (guest) => 2222 (host) (adapter 1)
==> core-01: Running 'pre-boot' VM customizations...
==> core-01: Booting VM...
==> core-01: Waiting for machine to boot. This may take a few minutes...
    core-01: SSH address: 127.0.0.1:2222
    core-01: SSH username: core
    core-01: SSH auth method: private key
==> core-01: Machine booted and ready!
==> core-01: Setting hostname...
==> core-01: Configuring and enabling network interfaces...
  • vagrant 初回起動時は ruby のインストールダイアログが現れます

vagrant 操作

  • 起動 vagrant up
  • 停止 vagratn halt
  • ssh接続 vagrant ssh
  • virtualbox host 側と guest OS についてのポートフォーワーディングなどの設定は、Vagrantfile に記述します

Vagrantfile 設定

  • coreos で実行する jupyter-notebook にホスト側から接続するためポートフォワードを設定する
# Vagrantfile 35行目を変更
$forworded_ports = {8888=>8888}
  • notepad で編集すると、エンコーディングや、ファイルフォーマットが崩れてしまうため、変更済みのVagrantfile をダウンロードして上書きいただいても.
Invoke-WebRequest -Uri "https://gist.githubusercontent.com/ysaito8015/fc046e45bffa9d0c996544bc6a07abba/raw/ceac932cda2a3b79bb929afff9db55b51ec555e5/Vagrantfile" -OutFile .\Vagrantfile

docker 実行

PS> vagrant ssh
PS> docker --version
Docker version 17.09.0-ce, build afdb6d4

参考にさせていただいた記事

Windows上にDocker環境を作る (VirtualBox + Vagrant + Container Linux)

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
What you can do with signing up
1