I always specify major and minor release numbers when using “pip install” inside a Dockerfile:
pip install --no-cache-dir beautifulsoup4==4.8.*
Another valid option would be to specify the major release:
pip install --no-cache-dir beautifulsoup4==4.*.*
Notes:
I don’t default to the latest because major releases it may contain breaking changes (e.g. dropping support for .xlsx in xlrd 2.0.0).
I don’t specify patch releases (e.g. 0.11.2) because they are too specific and some projects yank them such as python-Levenshtein.