環境
- OS : macOS High Sierra 10.13.6
- Docker : Docker for Mac 18.06.1-ce-mac73
- Base Image : CentOS7
- Nodebrew : v9.11.1
手順
Dockerfileの作成
Dockerfile
FROM centos:centos7
# epel
RUN yum -y install epel-release
# utilities
RUN yum -y install wget which
# git
RUN yum -y install git
# nodebrew + node.js
ENV NODE_VERSION v9.11.1
RUN wget git.io/nodebrew
RUN perl nodebrew setup
ENV PATH $HOME/.nodebrew/current/bin:$PATH
RUN echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> $HOME/.bashrc
RUN source $HOME/.bashrc && nodebrew install-binary $NODE_VERSION
RUN source $HOME/.bashrc && nodebrew use $NODE_VERSION
イメージのビルド
$ docker build -t n11sh1/nodebrew:v9.11.1 .
イメージの確認
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
n11sh1/nodebrew v9.11.1 218058a47150 2 minutes ago 708MB
コンテナの起動
$ docker run -it -d --name nodebrew n11sh1/nodebrew:v9.11.1
コンテナの状態確認
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
13bc5afc4dcc n11sh1/nodebrew:v9.11.1 "/bin/bash" 10 seconds ago Up 8 seconds nodebrew
コンテナに接続
$ docker exec -it nodebrew bash
[root@13bc5afc4dcc /]#
後処理
コンテナの停止
$ docker stop nodebrew
コンテナの削除
$ docker rm nodebrew
イメージの削除
$ docker rmi -f :image_id
さいごに
個人ブログにオリジナル(日本語&英語)をUPしています。
この記事が良いと感じた方は、そちらにもリアクション頂けると嬉しいです
https://blog.n11sh1.com