Running pip inside Docker container – won’t install desired version of module

  docker, dockerfile, pip, python

I am using the official python:3.9-slim Docker image and I am trying to install a specific version of a Python package using the following command inside my Dockerfile:

python3 -m pip --no-cache-dir install --user --upgrade ansible-core~=2.11

Outside of a Docker container this will install ansible-core 2.11.6 at this moment in time – this is the correct version as it is the latest 2.11 release.

However, I can’t get it to grab 2.11.x from inside my Docker container and it will only grab 2.12.0:

Collecting ansible-core~=2.11
  Downloading ansible-core-2.12.0.tar.gz (7.4 MB)

Is there something basic here that I am getting wrong?

Source: Python Questions

LEAVE A COMMENT