我对 Docker/Python 很陌生,并尝试更新现有 AWX 的 Docker Image 的 Dockerfile 以确保我拥有以下软件包的最新版本/usr/lib/python3.6/site-packages
/usr/lib/python3.6/site-packages/pip/_vendor/requests/sessions.py
/usr/lib/python3.6/site-packages/pip/_vendor/urllib3/connectionpool.py
/usr/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.py
/usr/lib/python3.6/site-packages/pip/_vendor/urllib3/util/retry.py
以下是我的环境信息:
Docker 版本 19.03.3,构建 a872fc2f86
Docker 基础镜像:centos:latest
我在其中进行更改的 Dockerfile 可在此处获得。
从到目前为止我从多个帖子/博客中读到的内容来看,这通常应该通过一个简单的更新:
pip3 install --upgrade pip
但是当我运行它时,我得到以下信息(并且它显示了包含local
在路径中的不同路径。
bash-4.4# pip3 install --upgrade pip
Requirement already up-to-date: pip in /usr/local/lib/python3.6/site-packages (19.3.1)
我什至尝试了以下方法,但这没有帮助:
bash-4.4# python3 -m ensurepip --upgrade
Requirement already up-to-date: setuptools in /usr/lib/python3.6/site-packages
Requirement already up-to-date: pip in /usr/local/lib/python3.6/site-packages
bash-4.4# pip3 install --upgrade setuptools
Requirement already up-to-date: setuptools in /usr/local/lib/python3.6/site-packages (42.0.2)
这就是在 Dockerfile 中应用上述更改的方式
在这个 Dockerfile 中,我在 Dockerfile 的第 124 行之后添加了以下行来更新 pip 包:
RUN yum update -y
RUN pip2 install --upgrade pip
RUN pip3 install --upgrade pip
来自 Dockerfile 的所需部分的快照
FROM centos:latest
USER root
# sync with installer/roles/image_build/templates/Dockerfile.j2
RUN dnf -y update && \
dnf -y install epel-release 'dnf-command(config-manager)' && \
dnf module -y enable 'postgresql:10' && \
dnf config-manager --set-enabled PowerTools && \
.
.
.
ansible \
python3-devel \
python3-libselinux \
python3-pip \
python3-psycopg2 \
python3-setuptools \
dnf-utils
ADD https://github.com/krallin/tini/releases/download/v0.14.0/tini /tini
RUN chmod +x /tini
RUN python3 -m ensurepip && pip3 install virtualenv
RUN pip3 install supervisor
ADD Makefile /tmp/Makefile
RUN mkdir /tmp/requirements
ADD requirements/requirements_ansible.txt \
requirements/requirements_ansible_uninstall.txt \
requirements/requirements_ansible_git.txt \
requirements/requirements.txt \
requirements/requirements_tower_uninstall.txt \
requirements/requirements_git.txt \
/tmp/requirements/
RUN cd /tmp && VENV_BASE="/var/lib/awx/venv" make requirements_awx requirements_ansible_py3
.
.
.
RUN echo "{{ awx_version }}" > /var/lib/awx/.tower_version
COPY {{ awx_sdist_file }} /tmp/{{ awx_sdist_file }}
RUN OFFICIAL=yes /var/lib/awx/venv/awx/bin/pip install /tmp/{{ awx_sdist_file }}
不知何故,这些变化没有反映在正确的路径上。有人可以建议如何更新里面的包:/usr/lib/python3.6/site-packages