Search code examples
configurationenvironment-variablesdefaultalpine-linux

Where to set system default environment variables in Alpine linux?


I know, with Ubuntu, you can set default values for environment variables in /etc/environment; I do not see that file in Alpine linux. Is there a different location for setting system-wide defaults?


Solution

  • It seems that /etc/profile is the best place I could find. At least, some environment variables are set there:

    export CHARSET=UTF-8
    export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    export PAGER=less
    export PS1='\h:\w\$ '
    
    umask 022
    
    for script in /etc/profile.d/*.sh ; do
            if [ -r $script ] ; then
                    . $script
            fi
    done
    

    According to the contents of /etc/profile, you can create a file with .sh extension in /etc/profile.d/ and you have to pass --login every time to load the env variables e.g docker exec -it container sh --login.