Search code examples
dockerpackagecontainersjuliapersistent-storage

how should I persistently save Julia packages in a Docker container


I'm running Julia on the raspberry pi 4. For what I'm doing, I need Julia 1.5 and thankfully there is a docker image of it here: https://github.com/Julia-Embedded/jlcross

My challenge is that, because this is a work-in-progress development I find myself adding packages here and there as I work. What is the best way to persistently save the updated environment?

Here are my problems:

  1. I'm having a hard time wrapping my mind around volumes that will save packages from Julia's package manager and keep them around the next time I run the container

  2. It seems kludgy to commit my docker container somehow every time I install a package.

Is there a consensus on the best way or maybe there's another way to do what I'm trying to do?


Solution

  • You can persist the state of downloaded & precompiled packages by mounting a dedicated volume into /home/your_user/.julia inside the container:

    $ docker run --mount source=dot-julia,target=/home/your_user/.julia [OTHER_OPTIONS]
    

    Depending on how (and by which user) julia is run inside the container, you might have to adjust the target path above to point to the first entry in Julia's DEPOT_PATH.

    You can control this path by setting it yourself via the JULIA_DEPOT_PATH environment variable. Alternatively, you can check whether it is in a nonstandard location by running the following command in a Julia REPL in the container:

    julia> println(first(DEPOT_PATH))
    /home/francois/.julia