在Alpine linux的哪里设置系统默认环境变量? [英] Where to set system default environment variables in Alpine linux?

查看:2256
本文介绍了在Alpine linux的哪里设置系统默认环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,在Ubuntu中,您可以在 / etc / environment 中设置环境变量的默认值。我在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?

推荐答案

似乎在 / etc / profile中是否存在其他位置? 是我能找到的最好的地方。至少在其中设置了一些环境变量:

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

根据<$ c $的内容c> / etc / profile ,您可以在 /etc/profile.d/中创建扩展名为 .sh 的文件。 ,您每次都必须传递-login 来加载环境变量,例如 docker exec -it container sh-登录

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.

这篇关于在Alpine linux的哪里设置系统默认环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆