I want to run docker in my homelab for any python related projects. To save diskspace and keep installed python packages across dockers consistent, I am looking for a way to share the installed python packages across the different services.
Services:
- Juypterlab (to create python scripts)
- Kestra (for automated execution of scripts)
- Couple of Flask apps
Expectation:
If I install pip install pandas in Jupyterlab, this package will also be available immediately in the Kestra container
I am quite new to docker and docker-compose.
You can use Docker Volumes
You can install your libraries on Volume.
You can define Volumes on
dockerfile,docker-composefile or oncliBut to share volumes, you should define named volumes.
You can do so using
cliordocker-composefile.cli
docker-compose file
A named volume is declared for the path /path/in/container(1/2). Docker will create a volume, named shared-volume, (folder on your pc) and mount it to /path/in/container(1/2) inside the container. This means that any data written to /path/in/container(1/2) inside the container will be stored in the volume and persist even after the container is stopped or removed.
Beware containers might overwrite each other's data stored on the volume.