拉取一个centos镜像
docker pull centos:7.6.1810
运行镜像;
docker run -d -t --name=centos centos:7.6.1810 bash
将python的tar包复制到容器内;
python.tar包地址:https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
docker cp Python-3.6.5.tgz centos:/
进入容器内
docker exec -it centos bash
mkdir -p /export/servers/
tar -zxvf Python-3.6.5.tgz -C /export/servers/
mv /export/servers/Python-3.6.5 /export/servers/python3.6
yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel
yum -y install readline-devel sqlite-devel gcc gcc-c++
yum -y install python-devel openldap-devel gettext gettext-common-devel gettext-devel
yum -y install automake autoconf libtool make
cd /export/servers/python3.6
vi Modules/Setup.dist
_socket socketmodule.c timemodule.c
SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
./configure --with-ssl --prefix=/export/servers/python3.6
make
make install
ln -s /export/servers/python3.6/bin/python3.6 /usr/bin/python3.6
ln -s /export/servers/python3.6/bin/pip3 /usr/bin/pip3.6
退出容器
exit
保存容器内容到一个新的基础镜像,可以用该镜像去制作别的镜像
docker commit centos zzx-python:3.6.5