I'm copying aliases.sh
into an alpine-based container:
FROM php:8.1-fpm-alpine AS php
COPY .docker/aliases.sh /etc/profile.d/
CMD ["php-fpm"]
When I log into the shell, my aliases won't work. If I run:
source /etc/profile
The suddenly start working. Maybe I need to add source
command into my Dockerfile
but.. it doesn't make sense to me.
Unix shells usually only load files like
/etc/profile
when they are started as a login shell. Ash, which is the default shell on Alpine, also does that.From the ash manual:
Starting the shell with
-l
should start it as a login shell and it should read/etc/profile
.ENV ENV="/etc/profile"
is how I solved. Added it to theDockerfile
. Now despite how I log in into the container (using Docker Desktop, VS Code docker extension, etc.) I'm able to use the aliases provided byaliases.sh
.