How to get /etc/profile to run automatically in Alpine / Docker

后端 未结 3 1268
执念已碎
执念已碎 2020-12-13 04:52

How can I get /etc/profile to run automatically when starting an Alpine Docker container interactively? I have added some aliases to an aliases.sh

3条回答
  •  醉梦人生
    2020-12-13 05:07

    As mentioned by Jinesh before, the default shell in Alpine Linux is ash

    localhost:~$ echo $SHELL
    /bin/ash
    localhost:~$ 
    

    Therefore simple solution is too add your aliases in .profile. In this case, I put all my aliases in ~/.ash_aliases

    localhost:~$ cat .profile 
    # ~/.profile
    
    # Alias
    if [ -f ~/.ash_aliases ]; then
        . ~/.ash_aliases
    fi
    
    localhost:~$ 
    

    .ash_aliases file

    localhost:~$ cat .ash_aliases
    alias a=alias
    alias c=clear
    alias f=file
    alias g=grep
    alias l='ls -lh'
    localhost:~$
    

    And it works :)

提交回复
热议问题