# Set correct environment variables. ENV HOME /root
# Regenerate SSH host keys. RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
## Install an SSH of your choice. ADD google_compute_engine.pub /tmp/your_key RUN cat /tmp/your_key >> /root/.ssh/authorized_keys && rm -f /tmp/your_key
## apt-get update RUN sed -i~ -e 's/archive.ubuntu.com/ftp.jaist.ac.jp/' /etc/apt/sources.list \ && apt-get update
## Japanese Environment RUN apt-get install -y language-pack-ja ENV LANG ja_JP.UTF-8 RUN update-locale LANG=ja_JP.UTF-8 RUN mv /etc/localtime /etc/localtime.orig RUN ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
## Development Environment RUN apt-get install -y emacs24-nox emacs24-el git
## Ruby RUN apt-get install -y ruby2.0 ruby2.0-dev RUN update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby2.0 10 RUN gem install bundler rubygems-update --no-rdoc --no-ri RUN update_rubygems
## dotfiles ADD dotfiles /root/
CMD ["/sbin/my_init"]
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
## Ruby 2.1.2 rbenv install RUN apt-get install -y build-essential RUN apt-get install -y zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt-dev RUN apt-get install -y sqlite3 libsqlite3-dev
RUN git clone https://github.com/sstephenson/ruby-build.git .ruby-build RUN .ruby-build/install.sh RUN rm -fr .ruby-build RUN ruby-build 2.1.2 /usr/local RUN gem update --system RUN gem install bundler --no-rdoc --no-ri
コンテナを起動してバージョンを確認します。
$ docker run -t -i --rm masato/baseimage /sbin/my_init /bin/bash*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh... *** Running /etc/rc.local... *** Booting runit daemon... *** Runit started as PID 13 *** Running /bin/bash... root@967fb55b5535:/# ruby -v ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux] root@967fb55b5535:/# gem -v 2.2.2 root@967fb55b5535:/# which ruby /usr/local/bin/ruby root@967fb55b5535:/# which gem /usr/local/bin/gem