0

The latest alpine docker image doesn't load the /etc/profile when starting up. See example of when it starts without /etc/profile loaded and when I load it.

[13:12]~$docker run --rm -it alpine
/ # . /etc/profile
ed2318ad9ac7:/#

How can I make it load the /etc/profile automatically upon start-up?

Vladimir
  • 417
  • 5
  • 20
  • 1
    `source` is not a supported command in `/bin/sh`. The POSIX-compliant alternative is the dot command, as in `. /etc/profile`. – Charles Duffy Feb 19 '18 at 16:42
  • 1
    Possible duplicate of [Getting a 'source: not found' error when using source in a bash script](https://stackoverflow.com/questions/670191/getting-a-source-not-found-error-when-using-source-in-a-bash-script), or [source command not found in sh shell](https://stackoverflow.com/questions/13702425/source-command-not-found-in-sh-shell). – Charles Duffy Feb 19 '18 at 16:43
  • @ldg, the fact that `/bin/sh` and not bash being used is right there in the OP's question, in the error specifying that it's `/bin/sh -c '...'` that's failing. (I'm assuming that they *have* installed bash, hence the `docker run` giving them a shell where `source` is available). – Charles Duffy Feb 19 '18 at 17:11
  • @Vladimir, ...by the way, even ignoring the `sh`-vs-`bash` difference, `RUN "source /etc/profile"` doesn't make sense, because each `RUN` command is invoked with a separate shell, and sourcing something into one shell won't change how subsequently-invoked shells behave (unless what you're doing is not setting shell state but actually modifying persistent content on disk, in which case there's no point to using `source` or `.` at all). – Charles Duffy Feb 19 '18 at 17:13
  • So it's not a duplicate of that issue for a different reason. @Vladimir - you should review how Docker `build` handles environment variables. – ldg Feb 19 '18 at 17:18
  • I edited the question to make more sense. I'm now loading it with ". /etc/profile". – Vladimir Feb 20 '18 at 11:15
  • Added ENV ENV="/etc/profile" – Vladimir Feb 21 '18 at 09:18

0 Answers0