Search code examples
pythondockerjupyter

Access docker container from jupyter server running on machine "outside container"?


I created a docker image running on my machine. I also have a Jupyter server running outside the container for code development. Is there a way for my jupyter server to access the contents of the container?

I was thinking if it is possible to setup some accessibility of my running jupyter server when I run the docker image... Is there something to do there? or should I set this up after I run the docker image?

Thanks!


Solution

  • Sounds like you want to mount a local directory as a volume on your docker container. Whenever you edit a file on your local machine in that directory (e.g. in Jupyter) it will be visible to the docker container and vice-versa.

    docker run --name my-container -v $(pwd)/my-directory:/home/my-directory -d my-image
    

    source: https://www.freecodecamp.org/news/docker-mount-volume-guide-how-to-mount-a-local-directory/