小编DJV*_*DJV的帖子

如何在 ash 中保留环境变量,Almquist shell?

如何让 ash 在启动时加载一些环境变量?

只需将它们放在 /etc/profile 中

/etc/profile 仅为登录 shell 读取;使用 docker(使用 alpine>busybox>ash)时经常弹出的非登录 shell 呢?

如果在环境变量 ENV 中指定,则非登录 shell 将读取文件

太好了,我如何确保设置了 ENV?它本身是一个环境变量,默认为空白。

本质上,我正在寻找一些保证 ash 可以读取的总体配置文件。对 busybox 使用的 ash 版本的偏好(BusyBox v1.28.4,如果你想准确的话)。这样的事情存在吗?是的,我知道 docker 中的 ENV 指令,它可用于在构建 docker 镜像时设置 $ENV;我仍然想知道这在 docker 之外是否可行。

我已经阅读了thisthis以试图理解。

作为旁注,谁能解​​释这种在高山的奇怪行为?

$docker run -it alpine
/ # echo $CHARSET #proof /etc/profile has not run

/ # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/ # env -i sh -c 'echo $PATH'
/sbin:/usr/sbin:/bin:/usr/bin
/ # echo $ENV

/ #
Run Code Online (Sandbox Code Playgroud)

当我们可以显示 /etc/profile 没有时,与为新 …

path environment-variables profile ash docker

7
推荐指数
1
解决办法
5245
查看次数

标签 统计

ash ×1

docker ×1

environment-variables ×1

path ×1

profile ×1