Because GitLab job need a shell: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/26501 Base Image scratch does have a shell, so it can not run the script and make job fail.