如何/etc/profile
以交互方式启动 Alpine Docker 容器时自动运行?我在aliases.sh
文件中添加了一些别名并将其放在 中/etc/profile.d
,但是当我使用 启动容器时docker run -it [my_container] sh
,我的别名没有激活。我. /etc/profile
每次都必须从命令行手动输入。
登录时是否需要其他一些配置/etc/profile
才能运行?我也有使用~/.profile
文件的问题。任何见解表示赞赏!
编辑:
根据 VonC 的回答,我提取并运行了他的示例ruby
容器。这是我得到的:
$ docker run --rm --name ruby -it codeclimate/alpine-ruby:b42
/ # more /etc/profile.d/rubygems.sh
export PATH=$PATH:/usr/lib/ruby/gems/2.0.0/bin
/ # env
no_proxy=*.local, 169.254/16
HOSTNAME=6c7e93ebc5a1
SHLVL=1
HOME=/root
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
/ # exit
尽管该/etc/profile.d/rubygems.sh
文件存在,但当我登录时它并没有运行,并且我的PATH
环境变量没有被更新。我使用了错误的docker run
命令吗?还缺少什么吗?有没有人得到~/.profile
或/etc/profile.d/
文件在 Docker 上与 Alpine 一起工作?谢谢!