Python 运行时的样本 Dockerfile
使用此样本 Dockerfile 向 Python 映像添加定制内容。
ARG base_image_tag
FROM ${base_image_tag}
# For installing OS packages, use root:root
# e.g.
USER root:root
RUN yum install -y gdb
# For installing to conda site-packages,
# use wmlfuser:condausers
# e.g.
USER wmlfuser:condausers
RUN umask 002 && \
pip install gensim
#
# Alternatively, for Installing to location other than conda site-packages.
# It can be installed to
# --target <any_file_system_dir_path>
# Provided <any_file_system_dir_path> full path is accessible to any user with group "condausers"
#
# Important:
# The <any_file_system_path> must then be added to the environment variable PYTHONPATH
#
# e.g
# use wmlfuser:condausers to install to the path /home/wmlfuser/mypkgs and add
# the path to PYTHONPATH environment variable
#
USER wmlfuser:condausers
RUN umask 002 && \
mkdir -p /home/wmlfuser/mypkgs && \
pip install pydot --target /home/wmlfuser/mypkgs
ENV PYTHONPATH=$PYTHONPATH:/home/wmlfuser/mypkgs
# If pip --user is used for installing package.
# The installation path needs to be explicitly added to PYTHONPATH
# e.g.
#
# for user wmlfuser:condausers it by default goes to user install directory
# (See the Python documentation for site.USER_BASE for full details.)
# use `python -m site --user-site` command to get the path.
#
# for wml-deployment-runtime-py39-1, it goes to
# /home/wmlfuser/.local/lib/python3.9/site-packages
#
#
<source-registry-url> 是 <external-image-registry-url> , <source-namespace> 是 下载基本映像部分中描述的 <namespace-in-external-registry> 。
对于 Podman:
podman build -t <custom-image-name>:<custom-image-tag> \
--build-arg base_image_tag=<downloaded-base-image> -f <path_to_dockerfile>
wml-deployment-runtime-py39-server.json)
父主题: 创建定制映像