Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Thank you for your answer, but it's not really what I asked. I'm aware that docker has tools you can use to pass environment variables around: >I know about the ENV directive in docker, which could be used to set $ENV when building a docker image; I'd still like to know if this is possible outside docker. What I'd like to know whether this is possible just in the context of the ash shell; also, tangentially, where the PATH variable in docker's alpine image comes from, because it seems like that's where I should look for my solution. Commented Feb 28, 2019 at 0:01
  • When you run /bin/sh outside of docker it will inherit the calling environment. So the question is simply "what is the calling environment". With your docker examples, I showed that what you're seeing is docker, itself, creating the calling environment. Ultimately, "how is /bin/sh" being called will determine if $ENV is set or not. Commented Feb 28, 2019 at 0:02
  • But in a fresh docker container, there is no calling environment; it's the equivalent of a boot, isn't it? The environment must be constructed from internal config files Commented Feb 28, 2019 at 0:04
  • No. The docker engine creates a runtime environment. Commented Feb 28, 2019 at 0:05
  • Ah; the shell received from docker run -it inherits environment variables from the docker engine itself; that makes sense, and explains the behavior of alpine. Now the question is how I can get ash do do my bidding and make sure it reads unrelated variables on startup (which may occur inside docker or without) Commented Feb 28, 2019 at 0:08