When modifying a container image with via ch-image modify using a script, we currently don't have a very user-friendly error message when trying to use a shell that doesn't exist via -S, e.g.
$ ch-image modify -S doesnotexist alpine:3.17 foo <<'EOF'
echo hello
EOF
-1* FROM alpine:3.17
-1. COPY ['/tmp/tmpw5_ww4op'] -> '/ch/script.sh'
updating existing image ...
-1. RUN.S doesnotexist /ch/script.sh
/bin/sh: doesnotexist: not found
something went wrong, rolling back ...
HEAD is now at 36233bb COPY ['/tmp/tmpw5_ww4op'] -> '/ch/script.sh'
error: build failed: RUN command exited with 127
Note that we do have a user-friendly error message for this same problem in interactive mode
$ ch-image modify -S doesnotexist alpine:3.17 foo
copying image from cache ...
ch-run[169241]: error: can't execve(2): doesnotexist: No such file or directory (ch_core.c:570 2)
error: can't run shell: doesnotexist
This is because in interactive mode we rely on the return value of a ch-run subprocess to determine whether the shell is there or not, but we don't perform such a check when traversing the Dockerfile parse tree in the script case.
When modifying a container image with via
ch-image modify
using a script, we currently don't have a very user-friendly error message when trying to use a shell that doesn't exist via-S
, e.g.Note that we do have a user-friendly error message for this same problem in interactive mode
This is because in interactive mode we rely on the return value of a
ch-run
subprocess to determine whether the shell is there or not, but we don't perform such a check when traversing the Dockerfile parse tree in the script case.