How does one initialize opam inside a Dockerfile?
I've created docker images with opam before but idk why this one is not working. I start from a image that already has opam but that doesn't seem to work, Dockerfile:
FROM continuumio/miniconda3
#FROM ocaml/opam:latest
FROM ruby:3.1.2
MAINTAINER Brando Miranda "brandojazz@gmail.com"
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ssh \
git \
m4 \
libgmp-dev \
wget \
ca-certificates \
rsync \
strace \
gcc \
rlwrap \
sudo \
lsb-release \
opam
# RUN apt-get clean all
# - most likely won't work, for now I don't have a solution for ruby on docker container ubuntu: https://stackoverflow.com/questions/74695464/why-cant-i-install-ruby-3-1-2-in-linux-docker-container?noredirect=1#comment131843536_74695464
#RUN apt-get install -y --no-install-recommends rbenv
#RUN apt-get install -y --no-install-recommends ruby-build
#RUN apt-get install -y --no-install-recommends ruby-full
#RUN rbenv install 3.1.2
#RUN rbenv global 3.1.2
# https://github.com/giampaolo/psutil/pull/2103
RUN useradd -m bot
# format for chpasswd user_name:password
RUN echo "bot:bot" | chpasswd
RUN adduser bot sudo
WORKDIR /home/bot
USER bot
ADD https://api.github.com/repos/IBM/pycoq/git/refs/heads/main version.json
# -- setup opam like VP's PyCoq
# https://stackoverflow.com/questions/74711264/how-does-one-initialize-opam-inside-a-dockerfile
RUN opam init --disable-sandboxing
Error:
(meta_learning) brandomiranda~/pycoq ❯ docker build -t brandojazz/pycoq:latest_arm .
[+] Building 8.6s (12/34)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 3.56kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 开发者_如何学JAVA 0.0s
=> [internal] load metadata for docker.io/library/ruby:3.1.2 0.0s
=> CACHED [stage-1 1/30] FROM docker.io/library/ruby:3.1.2 0.0s
=> CACHED https://api.github.com/repos/IBM/pycoq/git/refs/heads/main 0.0s
=> [stage-1 2/30] RUN apt-get update && apt-get install -y --no-install-recommends ssh git m4 libgmp-dev wget ca-cert 3.8s
=> [stage-1 3/30] RUN useradd -m bot 0.3s
=> [stage-1 4/30] RUN echo "bot:bot" | chpasswd 0.3s
=> [stage-1 5/30] RUN adduser bot sudo 0.3s
=> [stage-1 6/30] WORKDIR /home/bot 0.0s
=> [stage-1 7/30] ADD https://api.github.com/repos/IBM/pycoq/git/refs/heads/main version.json 0.0s
=> ERROR [stage-1 8/30] RUN opam init --disable-sandboxing 3.7s
------
> [stage-1 8/30] RUN opam init --disable-sandboxing:
#12 0.123 [NOTE] Will configure from built-in defaults.
#12 0.127 Checking for available remotes: rsync and local, git, mercurial.
#12 0.132 - you won't be able to use darcs repositories unless you install the darcs command on your system.
#12 0.132
#12 0.141
#12 0.141 <><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
#12 3.718 [ERROR] Could not update repository "default": Failed to extract archive /tmp/opam-7-6d07ae/index.tar.gz: "/bin/tar xfz /tmp/opam-7-6d07ae/index.tar.gz -C /home/bot/.opam/repo/default.new" exited with code 2
#12 3.718 [ERROR] Initial download of repository failed
------
executor failed running [/bin/sh -c opam init --disable-sandboxing]: exit code: 40
How do I fix this?
精彩评论