DockerでCentOS7上にRuby開発環境を構築
Dockerfile
FROM centos:7
# configure root user
RUN echo 'root:root' | chpasswd
# configure development user
ARG user=me
RUN groupadd ${user} && \
useradd -g ${user} -m ${user} -s /bin/bash && \
echo "${user}:${user}" | chpasswd
# install essentials
RUN yum -y update && \
yum -y install vim less wget zip unzip make git && \
yum clean all
# install Ruby Development environment
ARG version=2.6.3
RUN yum -y install gcc && \
cd /tmp && \
curl -SL https://cache.ruby-lang.org/pub/ruby/2.6/ruby-${version}.tar.gz | tar xz && \
cd ruby-${version} && \
./configure && \
make && \
make install && \
cd /tmp && \
rm -rf ruby-${version}
イメージビルド
docker image build -f ./Dockerfile -t centos7:dev_ruby .
コンテナ生成&起動
docker container run -i -t --rm centos7:dev_ruby su - me
ホストをマウントする場合
docker container run -i -t --rm \
--mount type=bind,src=/Users/me/code,dst=/home/me/code \
centos7:dev_ruby su - me
DockerでUbuntu18.04上にRuby開発環境を構築
Dockerfile
FROM ubuntu:18.04
# configure root user
RUN echo 'root:root' | chpasswd
# configure development user
ARG user=me
RUN groupadd ${user} && \
useradd -g ${user} -m ${user} -s /bin/bash && \
echo "${user}:${user}" | chpasswd
# install essentials
RUN apt update && apt -y upgrade && \
apt -y install vim less wget curl zip make git && \
apt clean
# install Ruby Development environment
ARG version=2.6.3
RUN apt -y install gcc && \
cd /tmp && \
curl -SL https://cache.ruby-lang.org/pub/ruby/2.6/ruby-${version}.tar.gz | tar xz && \
cd ruby-${version} && \
./configure && \
make && \
make install && \
cd /tmp && \
rm -rf ruby-${version}
イメージビルド
docker image build -f ./Dockerfile -t ubuntu18.04:dev_ruby .
コンテナ生成&起動
docker container run -i -t --rm ubuntu18.04:dev_ruby su - me
ホストをマウントする場合
docker container run -i -t --rm \
--mount type=bind,src=/Users/me/code,dst=/home/me/code \
ubuntu18.04:dev_ruby su - me