Julia应用程序的Docker到Apptainer/奇点图像:manifest_usage.toml只读文件系统

hwamh0ep  于 2023-01-04  发布在  Docker
关注(0)|答案(1)|浏览(118)

我试图创建一个docker映像,它也可以在singularity中为软件Whippet(https://github.com/timbitz/Whippet.jl)工作. docker映像工作正常,但是当我尝试使用singularity(singularity-ce版本3.9.5)时,它不能写manifest_usage. toml(这是可以理解的,因为在singularity中命令是由用户执行的,而不是像在docker中那样由根执行).
下面是我的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"]

有什么建议吗?
我尝试为JULIA_DEPOT_PATH(也是默认的~/. julia)使用不同的位置来创建新用户,但我遇到了同样的问题。

docker run cloxd/whippet:1.6.1 -h

运行良好,同时具有奇异性的相同命令会引起以下错误

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
a11xaf1n

a11xaf1n1#

最后我找到了一个可行的解决方案:初始化之后,只需将/tmp/添加到JULIA_DEPO_PATH,Julia使用的是/tmp/logs/manifest_usage. toml,而不是受保护的/depot/logs/manifest_usage. toml。

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"]

相关问题