Where to set default environment variables in Alpine linux?

I know that with Ubuntu you can set default values ​​for environment variables in /etc/environment ; I do not see this file in Alpine linux. Is there another place to set system-wide defaults?

+15
environment-variables default configuration alpine
source share
2 answers

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 the extension .sh in /etc/profile.d/ and you need to pass --login each time to load env variables, for example docker exec -it container sh --login .

+19
source share

If you are talking about an Alpine Docker image, then you can define these env variables inside the Dockerfile, as shown below. Here you do not need to go through --login every time. These variables will be automatically available throughout the system.

 FROM alpine ENV GITHUB_TOKEN=XXXXXXXXXXXXXXXXXXXXXXX \ COMPOSER_HOME=/home/deploy/.composer 

You can also define your alias, env, etc. Inside / etc / profile and define the ENV inside the Dockerfile, as shown below, to automatically create a profile.

 FROM alpine ENV GITHUB_TOKEN=XXXXXXXXXXXXXXXXXXXXXXX \ COMPOSER_HOME=/home/deploy/.composer ENV ENV="/etc/profile" 
0
source share

All Articles