北京改网站,呼和浩特网站制作 建设,济南哪里做网站好,商旅网站制作docker构建python3.7镜像#xff1a;https://zhuanlan.zhihu.com/p/137288195 FROM#xff1a;需要什么环境 ENV#xff1a;修改path#xff0c;即增加/usr/local/bin这个环境变量 ADD#xff1a;将本地代码放到虚拟容器中#xff0c;它有两个参数#xff0c;第一个是 .…docker构建python3.7镜像https://zhuanlan.zhihu.com/p/137288195 FROM需要什么环境 ENV修改path即增加/usr/local/bin这个环境变量 ADD将本地代码放到虚拟容器中它有两个参数第一个是 . 代表本地当前路径第二个参数是/code代表虚拟容器中的路径即将本地项目的所有内容放到虚拟容器的/code目录下以便在虚拟容器中运行代码 WORKDIR指定工作目录也就是刚才的/code在虚拟容器中的目录 RUN执行某些环境准备工作docker容器中只有python3环境还需要python的库这里安装那些库 CMD运行项目的命令行命令
打开python镜像地址 https://hub.docker.com/_/python 点击红色部分出现
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA apply-templates.sh
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#FROM buildpack-deps:bullseye# ensure local python is preferred over distribution python
ENV PATH /usr/local/bin:$PATH# http://bugs.python.org/issue19846
# At the moment, setting LANGC on a Linux system *fundamentally breaks Python 3*, and thats not OK.
ENV LANG C.UTF-8# runtime dependencies
RUN set -eux; \apt-get update; \apt-get install -y --no-install-recommends \libbluetooth-dev \tk-dev \uuid-dev \; \rm -rf /var/lib/apt/lists/*ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
ENV PYTHON_VERSION 3.7.13RUN set -eux; \\wget -O python.tar.xz https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz; \wget -O python.tar.xz.asc https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc; \GNUPGHOME$(mktemp -d); export GNUPGHOME; \gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys $GPG_KEY; \gpg --batch --verify python.tar.xz.asc python.tar.xz; \command -v gpgconf /dev/null gpgconf --kill all || :; \rm -rf $GNUPGHOME python.tar.xz.asc; \mkdir -p /usr/src/python; \tar --extract --directory /usr/src/python --strip-components1 --file python.tar.xz; \rm python.tar.xz; \\cd /usr/src/python; \gnuArch$(dpkg-architecture --query DEB_BUILD_GNU_TYPE); \./configure \--build$gnuArch \--enable-loadable-sqlite-extensions \--enable-optimizations \--enable-option-checkingfatal \--enable-shared \--with-system-expat \--with-system-ffi \--without-ensurepip \; \nproc$(nproc); \make -j $nproc \
# setting PROFILE_TASK makes --enable-optimizations reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916PROFILE_TASK-m test.regrtest --pgo \test_array \test_base64 \test_binascii \test_binhex \test_binop \test_bytes \test_c_locale_coercion \test_class \test_cmath \test_codecs \test_compile \test_complex \test_csv \test_decimal \test_dict \test_float \test_fstring \test_hashlib \test_io \test_iter \test_json \test_long \test_math \test_memoryview \test_pickle \test_re \test_set \test_slice \test_struct \test_threading \test_time \test_traceback \test_unicode \ \; \make install; \\
# enable GDB to load debugging data: https://github.com/docker-library/python/pull/701bin$(readlink -ve /usr/local/bin/python3); \dir$(dirname $bin); \mkdir -p /usr/share/gdb/auto-load/$dir; \cp -vL Tools/gdb/libpython.py /usr/share/gdb/auto-load/$bin-gdb.py; \\cd /; \rm -rf /usr/src/python; \\find /usr/local -depth \\( \\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \-o \( -type f -a \( -name *.pyc -o -name *.pyo -o -name *.a \) \) \-o \( -type f -a -name wininst-*.exe \) \\) -exec rm -rf {} \; \\ldconfig; \\python3 --version# make some useful symlinks that are expected to exist (/usr/local/bin/python and friends)
RUN set -eux; \for src in idle3 pydoc3 python3 python3-config; do \dst$(echo $src | tr -d 3); \[ -s /usr/local/bin/$src ]; \[ ! -e /usr/local/bin/$dst ]; \ln -svT /usr/local/bin/$src /usr/local/bin/$dst; \done# if this is called PIP_VERSION, pip explodes with ValueError: invalid truth value VERSION
ENV PYTHON_PIP_VERSION 22.0.4
# https://github.com/docker-library/python/issues/365
ENV PYTHON_SETUPTOOLS_VERSION 57.5.0
# https://github.com/pypa/get-pip
ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/38e54e5de07c66e875c11a1ebbdb938854625dd8/public/get-pip.py
ENV PYTHON_GET_PIP_SHA256 e235c437e5c7d7524fbce3880ca39b917a73dc565e0c813465b7a7a329bb279aRUN set -eux; \\wget -O get-pip.py $PYTHON_GET_PIP_URL; \echo $PYTHON_GET_PIP_SHA256 *get-pip.py | sha256sum -c -; \\export PYTHONDONTWRITEBYTECODE1; \\python get-pip.py \--disable-pip-version-check \--no-cache-dir \--no-compile \pip$PYTHON_PIP_VERSION \setuptools$PYTHON_SETUPTOOLS_VERSION \; \rm -f get-pip.py; \\pip --versionCMD [python3]