0

I've created Docker images with opam before, but I don't know why this one is not working. I start from an 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

# - This most likely won't work. For now I don't have a solution for a 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                                                                                                                    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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
  • 3
    What I tend to do when container setup fails like this is build the container up to that point but with bash as the entrypoint, then manually run the command and poke about to find out why it is failing. – Richard Huxton Dec 07 '22 at 10:00

0 Answers0