Last active
March 8, 2018 22:09
-
-
Save RyosukeKamei/33ec5b1bde99d3553f16d2d969f46285 to your computer and use it in GitHub Desktop.
Docker上のCentOSにPython3と、関連ライブラリpip, virtualenvとフレームワークDjango, bottle, Flaskのインストール!これらをまとめたDockerfile付き! ref: https://qiita.com/RyosukeKamei/items/eca9687162b7fe122094
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pyenv | |
export PYENV_ROOT="$HOME/.pyenv" | |
export PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init -)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install autoconf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install automake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vi /etc/skel/.bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source /etc/skel/.bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install bison |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install bzip2 | |
# yum -y install bzip2-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker run -it centos | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cat /etc/redhat-release | |
CentOS Linux release 7.2.1511 (Core) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OSはCentOS | |
FROM centos:latest | |
# 各パッケージをインストール | |
# pipやvirtualenvインストールも想定しています。 | |
RUN yum -y update | |
RUN yum -y groupinstall "Development Tools" | |
RUN yum -y install \ | |
kernel-devel \ | |
kernel-headers \ | |
gcc-c++ \ | |
patch \ | |
libyaml-devel \ | |
libffi-devel \ | |
autoconf \ | |
automake \ | |
make \ | |
libtool \ | |
bison \ | |
tk-devel \ | |
zip \ | |
wget \ | |
tar \ | |
gcc \ | |
zlib \ | |
zlib-devel \ | |
bzip2 \ | |
bzip2-devel \ | |
readline \ | |
readline-devel \ | |
sqlite \ | |
sqlite-devel \ | |
openssl \ | |
openssl-devel \ | |
git \ | |
gdbm-devel \ | |
python-devel | |
# Python3.5.2をインストール | |
# Python3.5.2をダウンロード | |
WORKDIR /root | |
RUN wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz | |
RUN tar xzvf Python-3.5.2.tgz | |
# makeでインストール | |
WORKDIR ./Python-3.5.2 | |
RUN ./configure --with-threads | |
RUN make install | |
# pipインストール(最新版) | |
RUN wget https://bootstrap.pypa.io/get-pip.py | |
RUN python get-pip.py | |
# readlineインストール | |
RUN pip install readline | |
# virtualenvインストール | |
RUN pip install virtualenv | |
# Djangoインストール | |
RUN pip install django | |
# おまけ | |
# Django以外のフレームワークインストール | |
# bottleインストール | |
# RUN pip install bottle | |
# Flaskインストール | |
# RUN pip install Flask | |
WORKDIR /root | |
CMD ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install gcc-c++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install gdbm-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install libffi-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install libtool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install libyaml-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cd ./Python-3.5.2 | |
# ./configure --with-threads | |
# make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wget https://bootstrap.pypa.io/get-pip.py | |
# python get-pip.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip3 install bottle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip3 install django |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip3 install Flask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip3 --version | |
pip 8.1.2 from /root/.pyenv/versions/3.5.2/lib/python3.5/site-packages (python 3.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git clone https://github.com/yyuu/pyenv.git /root/.pyenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum install python-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cd /root | |
# wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz | |
# tar xzvf Python-3.5.2.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python -V | |
Python 2.7.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python -V | |
Python 3.5.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pyenv install --list | |
Available versions: | |
2.1.3 | |
2.2.3 | |
2.3.7 | |
... | |
3.5.1 | |
3.5.2 | |
3.6.0a1 | |
3.6.0a3 | |
3.6-dev | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker build -t {任意のイメージ名} . | |
# 例 | |
$ docker build -t ms-06r-1a-000 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip3 install readline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install tk-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y groupinstall "Development Tools" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# virtualenv --version | |
15.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip3 install virtualenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cd {適当なフォルダ} | |
# virtualenv sample | |
# ls | |
sample | |
# source sample/bin/activate | |
(sample) # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install wget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker pull centos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker images | |
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE | |
centos latest 3508c878e883 2 weeks ago 196.8 MB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker run -it --name {任意のコンテナ名} {作成したイメージ名} /bin/bash | |
# 例 | |
$ docker run -it --name ms-06r-1a-000-python ms-06r-1a-000 /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum install gcc zlib-devel bzip2 bzip2-devel readline readline-devel sqlite sqlite-devel openssl openssl-devel git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pyenv install 3.5.2 | |
Downloading Python-3.5.2.tar.xz... | |
-> https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz | |
Installing Python-3.5.2... | |
# pyenv global 3.5.2 | |
# pyenv rehash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install kernel-devel | |
# yum -y install kernel-headers | |
# yum -y install openssl-devel | |
# yum -y install readline | |
# yum -y install readline-devel | |
# yum -y install zlib | |
# yum -y install zlib-devel | |
# yum -y install sqlite | |
# yum -y install sqlite-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pyenv version | |
system (set by /root/.pyenv/version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y update | |
# yum -y groupinstall "Development Tools" | |
# yum -y install \ | |
kernel-devel \ | |
kernel-headers \ | |
gcc-c++ \ | |
patch \ | |
libyaml-devel \ | |
libffi-devel \ | |
autoconf \ | |
automake \ | |
make \ | |
libtool \ | |
bison \ | |
tk-devel \ | |
zip \ | |
wget \ | |
tar \ | |
gcc \ | |
zlib \ | |
zlib-devel \ | |
bzip2 \ | |
bzip2-devel \ | |
readline \ | |
readline-devel \ | |
sqlite \ | |
sqlite-devel \ | |
openssl \ | |
openssl-devel \ | |
git \ | |
gdbm-devel \ | |
python-devel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment