Docker should take care of this if you set up the Dockerfile correctly. If you are using a requirements.txt file check out this medium post.
You can also define all the packages directly in the Docker file, e.g.:
RUN pip install python-dateutil
Docker won’t reinstall packages that are already at the latest version.