R使いのためのDocker「Rocker」をScalewayの物理サーバで動かす

フランスのベアメタルサーバホスティングサービスScalewayが前から気になってたので使ってみました。

Scalewayでは、月€2.99を払ってdeveloper accountにアップグレードするとDockerファイルをビルドしてつくった自作イメージを使うことができます。

www.scaleway.com

Dockerサーバをつくる

↑のドキュメントを読むと、Requirementsとして

  • You have an account and are logged into cloud.scaleway.com
  • You have configured your SSH Key
  • You have an additional volume attached to your server
  • Your server is running the Docker image from the InstantApps

という記載があります。言われた通り、イメージにはImageHubからDockerを指定して、ボリュームをひとつ作ります。

f:id:yutannihilation:20160716174623p:plain

helloworldをもってくる

Makefileを使いたいだけなんですが、このイメージを使います。

git clone https://github.com/scaleway/image-helloworld
cd image-helloworld

RockerのDockerfileをとってくる

元のDockerfileは要らないので消して、RockerのDockerfileを取ってきます。

rm Dockerfile
wget https://raw.githubusercontent.com/rocker-org/rocker/master/r-base/Dockerfile

イメージをビルド

ベースイメージはScaleway公式のものでなくてもいい気がするんですけど、よく分からないので公式のものをFROMに指定しておきます。

## Emacs, make this -*- mode: sh; -*-

FROM scaleway/debian:amd64-sid

そして、make installします。これで追加のボリュームにイメージが書き込まれるので、そのスナップショットを別のサーバのイメージとして使うことができます。

make install

スナップショットを取る

まず電源を落とします(ただこれはsudo haltだとうまく落ちなくて、結局コンソールから電源を落としました。)

sudo halt

Volumeのスナップショットをとります。

f:id:yutannihilation:20160716182130p:plain

Volumeのスナップショットを使って新しいサーバをつくる

こんな感じ。

f:id:yutannihilation:20160716182349p:plain

Rを立ち上げる

立ち上がりました。

root@scw-xxxxx:~# R

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

>

感想

Scaleway、便利っぽいけどところどころよくわからない。。もうちょっとドキュメントが整ってアジアリージョンも選べるようになったらまた使ってみたいと思います。