0

Container 1 : I have a docker container which is spawned by a Dockerfile image that i built serving Python dependencies to a specific use-case. This container is mount to my file system project directory to /source directory in the Docker container.

Container 2 : Another container contains Jupyter notebook and it is only configured to use Jupyter notebook.

I don't use Jupyter notebook all the time for Python developement, i use my code editor instead. I just want an easier way to mount Jupyter notebook when i want to and edit my project files.

Now, can i mount Container-2 to Container-1 such that contents in the /source directory in Container-1 is persisted to my project directory while enabling Container-1 and Conatiner-2 to take up a shared space? In my case i want Container-1 to be mount to my file system to /source and I want the Jupyter Notebook, running in Container-2 to be able to edit files inside the /source directory in Container-1.

  • You can mount that `/source` directory of host with multiple containers. Check this https://stackoverflow.com/questions/42854936/can-i-mount-same-volume-to-multiple-docker-containers – mchawre Jul 07 '19 at 11:49
  • Thanks @mchawre for such a quick reply. I'll checkout. –  Jul 07 '19 at 11:52
  • This didn't solve my problem since i cant access the Python dependencies installed in Container-1 while using Jupyter notebook in Container-2. –  Jul 07 '19 at 11:58
  • Have you gone through these links https://forums.docker.com/t/question-on-shared-libraries/45515 https://stackoverflow.com/questions/35863608/shared-library-in-containers – mchawre Jul 07 '19 at 13:06
  • Yes. I went through them. But it doesn't make it clear on how to use python packages in Container 1 inside Container 2. It's a bad approach i reckon. –  Jul 07 '19 at 16:24

1 Answers1

0

if I'm understanding correctly, what you are trying to do is using one container installed libs in another container

I think that this approach is bad, since there might be some problems with OS level dependencies that are missing. The first possible solution is installing the dependencies in both containers, or at least using the 1st docker image as base to the 2nd

If you yet rather doing it your way, you can try mounting volume between the 1st container virtual env / site-packages with the 2nd

gCoh
  • 2,719
  • 1
  • 22
  • 46
  • Hey @gCoh, Thanks for your answer. I tried your approach. It turns out in order to connect to another container, there's `--volumes-from` attribute but it mounts the container to the mount point of container-1. So i can't mount it to `/site-packages`. I'd appreciate if there's a better way of doing this without causing system vulnurability. –  Jul 07 '19 at 12:46