基于Ubuntu16.04的Python3.7镜像构建
Dockerfile
FROM ubuntu:16.04
MAINTAINER linvaux <[email protected]>
WORKDIR /opt
RUN sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list && \
sed -i "s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list && \
apt-get update && \
apt-get upgrade -y
RUN apt-get install -y gcc make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev
RUN wget https://mirrors.huaweicloud.com/python/3.7.8/Python-3.7.8.tgz && \
tar -vxf Python-3.7.8.tgz && \
mv Python-3.7.8 /usr/local/python378 && \
cd /usr/local/python378 && \
./configure --prefix=/usr/local/python378 --enable-loadable-sqlite-extensions --with-ssl &&\
make -j$(nproc) && \
make install -j$(nproc) && \
ln -s /usr/local/python378/bin/python3.7 /usr/bin/python3 && \
ln -s /usr/local/python378/bin/pip3 /usr/bin/pip3 && \
mkdir /root/.pip && \
echo "[global]" > /root/.pip/pip.conf && \
echo "index-url=https://pypi.douban.com/simple/" >> /root/.pip/pip.conf && \
echo "[install]" >> /root/.pip/pip.conf && \
echo "trusted-host=pypi.douban.com" >> /root/.pip/pip.conf
RUN rm -rf Python-3.7.8.tgz
构建命令
docker build -t ubuntu-python378 .