Skip to content

Instantly share code, notes, and snippets.

@RyosukeKamei
Last active March 8, 2018 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyosukeKamei/33ec5b1bde99d3553f16d2d969f46285 to your computer and use it in GitHub Desktop.
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
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# yum -y install autoconf
# yum -y install automake
# source /etc/skel/.bash_profile
# yum -y install bison
# yum -y install bzip2
# yum -y install bzip2-devel
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
# 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"]
# yum -y install gcc-c++
# yum -y install gdbm-devel
# yum -y install libffi-devel
# yum -y install libtool
# yum -y install libyaml-devel
# yum -y install make
# cd ./Python-3.5.2
# ./configure --with-threads
# make install
# yum -y install patch
# wget https://bootstrap.pypa.io/get-pip.py
# python get-pip.py
# pip3 --version
pip 8.1.2 from /root/.pyenv/versions/3.5.2/lib/python3.5/site-packages (python 3.5)
# git clone https://github.com/yyuu/pyenv.git /root/.pyenv
# yum install python-devel
# cd /root
# wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
# tar xzvf Python-3.5.2.tgz
# 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
...
$ docker build -t {任意のイメージ名} .
# 例
$ docker build -t ms-06r-1a-000 .
# pip3 install readline
# yum -y install tk-devel
# yum -y groupinstall "Development Tools"
# virtualenv --version
15.0.2
# cd {適当なフォルダ}
# virtualenv sample
# ls
sample
# source sample/bin/activate
(sample) #
# yum -y install wget
# yum -y install zip
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos latest 3508c878e883 2 weeks ago 196.8 MB
$ docker run -it --name {任意のコンテナ名} {作成したイメージ名} /bin/bash
# 例
$ docker run -it --name ms-06r-1a-000-python ms-06r-1a-000 /bin/bash
# yum install gcc zlib-devel bzip2 bzip2-devel readline readline-devel sqlite sqlite-devel openssl openssl-devel git
# 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
# 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
# pyenv version
system (set by /root/.pyenv/version)
# 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