dockerjuliasingularity-containerapptainer

Docker to Apptainer/Singularity image for Julia application: manifest_usage.toml Read-only file system


I'm trying to create a docker image that could work also in singularity for the software Whippet ( https://github.com/timbitz/Whippet.jl ). The docker image works fine, but when I try to use it with singularity (singularity-ce version 3.9.5), It's not able to write the manifest_usage.toml ( that is comprehensible, since in singularity the command is executed by the user and not by the root as in docker).

Here's my Dockerfile:

FROM julia:bullseye

LABEL version=v1.6.1

RUN apt-get update && apt-get install -y git 

RUN mkdir /depot
ENV JULIA_PATH=/usr/local/julia
ENV JULIA_DEPOT_PATH=/depot
ENV JULIA_PROJECT=/whippet


RUN mkdir /whippet/ && cd /whippet && \
    git clone --depth 1 --branch v1.6.1  https://github.com/timbitz/Whippet.jl.git . && \
    julia --project=/whippet -e 'using Pkg; Pkg.instantiate(); Pkg.precompile();' 

RUN chmod 777 -R /depot/
    
ENV PATH="/whippet/bin/:${PATH}"

RUN whippet-quant.jl -h || echo "Done"
RUN whippet-index.jl -h || echo "Done"
RUN whippet-delta.jl -h || echo "Done"


ENTRYPOINT ["whippet-quant.jl"]

Any suggestions?

I tried using diffrent locations for the JULIA_DEPOT_PATH ( also the default ~/.julia ) creating a new user, but I got the same issue. the command

docker run cloxd/whippet:1.6.1 -h

works nicely, meanwhile the same command with singularity raise the following error

singularity run  docker://cloxd/whippet:1.6.1 
INFO:    Using cached SIF image
Whippet v1.6.1 loading... 
  Activating project at `/whippet`
ERROR: LoadError: SystemError: opening file "/depot/logs/manifest_usage.toml": Read-only file system
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base ./error.jl:176
  [2] #systemerror#80
    @ ./error.jl:175 [inlined]
  [3] systemerror
    @ ./error.jl:175 [inlined]
  [4] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Nothing, append::Bool)
    @ Base ./iostream.jl:293
  [5] open(f::Pkg.Types.var"#44#46"{String}, args::String; kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:append,), Tuple{Bool}}})
    @ Base ./io.jl:382
  [6] write_env_usage(source_file::String, usage_filepath::String)
    @ Pkg.Types /usr/local/julia/share/julia/stdlib/v1.8/Pkg/src/Types.jl:487
  [7] Pkg.Types.EnvCache(env::Nothing)
    @ Pkg.Types /usr/local/julia/share/julia/stdlib/v1.8/Pkg/src/Types.jl:345
  [8] EnvCache
    @ /usr/local/julia/share/julia/stdlib/v1.8/Pkg/src/Types.jl:325 [inlined]
  [9] add_snapshot_to_undo(env::Nothing)
    @ Pkg.API /usr/local/julia/share/julia/stdlib/v1.8/Pkg/src/API.jl:1862
 [10] add_snapshot_to_undo
    @ /usr/local/julia/share/julia/stdlib/v1.8/Pkg/src/API.jl:1858 [inlined]
 [11] activate(path::String; shared::Bool, temp::Bool, io::Base.TTY)
    @ Pkg.API /usr/local/julia/share/julia/stdlib/v1.8/Pkg/src/API.jl:1700
 [12] activate(path::String)
    @ Pkg.API /usr/local/julia/share/julia/stdlib/v1.8/Pkg/src/API.jl:1659
 [13] top-level scope
    @ /whippet/bin/whippet-quant.jl:12
in expression starting at /whippet/bin/whippet-quant.jl:12


Solution

  • Finally I found a working solution: after the initialization, it's enough to add /tmp/ to the JULIA_DEPO_PATH and Julia is using /tmp/logs/manifest_usage.toml instead of the protected /depot/logs/manifest_usage.toml. For clarity, here's the Dockerfile

    
    FROM julia:bullseye
    
    LABEL version=v1.6.1
    
    RUN apt-get update && apt-get install -y git 
    
    RUN mkdir /depot
    ENV JULIA_PATH=/usr/local/julia
    ENV JULIA_DEPOT_PATH=/depot
    ENV JULIA_PROJECT=/whippet
    
    
    RUN mkdir /whippet/ && cd /whippet && \
        git clone --depth 1 --branch v1.6.1  https://github.com/timbitz/Whippet.jl.git . && \
        julia --project=/whippet -e 'using Pkg; Pkg.instantiate(); Pkg.precompile();' 
    
    RUN chmod 777 -R /depot/
        
    ENV PATH="/whippet/bin/:${PATH}"
    
    RUN whippet-quant.jl -h || echo "Done"
    RUN whippet-index.jl -h || echo "Done"
    RUN whippet-delta.jl -h || echo "Done"
    
    ENV JULIA_DEPOT_PATH="/tmp/:${JULIA_DEPOT_PATH}"
    
    
    ENTRYPOINT ["whippet-quant.jl"]