main/bash: /etc/profile breaks PATH settings in Docker/OCI containers
Hi,
when using bash in a alpine based docker/OCI image, the PATH variable is overridden/broken, if set in the image meta info.
It is common that environment variables, including PATH, are set via the ENV command in Dockerfiles. Their values are stored in the image meta data and can be viewed with podman image inspect IMAGENAME. When the container starts, these environment variables are automatically set and passed through.
bash, however, enforces overriding the PATH variable in /etc/profile with
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
thus overriding and destroying any set environments.
This breaks, e.g., the ruby containers, where "PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", is set in the image meta data.
Gem Binaries, which are installed in /usr/local/bundle/bin are not found then by bash.
regards