ホストでコンテナを作成する
docker run -dit -p 49152:3000 --name rails centos:7
docker exec -it rails bash
コンテナでrailsをインストールする
yum install -y gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel git bzip2 make ruby-devel libffi-devel sqlite-devel
git clone https://github.com/creationix/nvm.git ~/.nvm
source ~/.nvm/nvm.sh
echo 'if [[ -s ~/.nvm/nvm.sh ]];' >> ~/.bash_profile
echo ' then source ~/.nvm/nvm.sh' >> ~/.bash_profile
echo 'fi' >> ~/.bash_profile
nvm ls-remote
nvm install stable
git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
echo 'export RBENV_ROOT="/usr/local/rbenv"' >> ~/.bash_profile
echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
rbenv --version
git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
rbenv install -l
rbenv install -v 2.5.0
rbenv rehash
rbenv global 2.5.0
ruby -v
gem update --system
gem install --no-ri --no-rdoc rails
gem install bundler
rbenv rehash
rails -v
サンプルプロジェクトを作ってみる
rails new sample
cd sample
rails server
http://{$IP}:49152/ にアクセスし、”Yay! You’re on Rails!“の画面が表示されることを確認する