Running Julia in Jupyter from within a Docker container does not allow precompilation of packages

I’ve been experimenting with Julia, and I run it from within a Docker container. This works great most of the time, but one small issue has been bugging me. Each time I launch or restart the kernel packages are precompiled anew, costing up to 20 seconds or more the first time I load a package.

I tried triggering the precompilation in the Dockerfile:

    FROM jupyter/datascience-notebook
    
    RUN julia -e 'using Pkg; Pkg.add.(["CSV", "DataFrames", "DataFramesMeta", "Gadfly"]); Pkg.precompile()'

But this still triggers the recompilation each time I load the kernel running inside the container. Any tips or suggestions?