Skip to content

[WIP] Replace bash with bash → ash → sh fallthrough

username-removed-366499 requested to merge (removed):compat/bash-to-sh into master

This modifies the docker-entrypoint.sh script to use /bin/sh as the program loader instead of /bin/bash. This is under the assumption that the most available shell is going to be sh and not bash, as is the case in smaller or minimal environments (such as in busybox or Alpine Linux, where bash is not available, but ash and sh are). A more correct loader could be written in C or Go that could check for what shells are available without requiring even sh, but for now, it seems like sh is the most reasonable option.

By default, this should function exactly the same as it already would when run for a container using bash. If the container does not contain bash, it then falls back to ash, which is the preferred shell in busybox and Alpine Linux, and finally sh, which we know is the minimum option of the three if the script is running. Further shells could be tested for.

I've tested this with containers for CentOS 7, Ubuntu (14.04, though it should be the same for others, bash has been a mainstay there), busybox (glibc, uclibc, and musl tags, nothing version specific), and Alpine Linux (3.1, 3.2, and 3.3 specifically). All work as I'd expect them to, considering how simple the change is, but they also represent the images I have to deal with most often, so grain of salt.

This is needed because otherwise we're limited to only using containers with bash. It still requires we have containers with shells, but that seems fine to me.

This is intended to address gitlab-org/gitlab-ci-multi-runner#362.


Note that this will still probably require some changes to the runner program as well to ensure it doesn't assume bash is the only shell it can use.

Merge request reports