Score:0

How env var is resolved in distroless container?

in flag

I am using a distroless container for my app and normally I start my app as follow:

java -jar $ARG1 $ARG2 app.jar

In distroless image I gave only

CMD ["app.jar"]

Args are predefined env var in container or local machine. The point here is that AFAIK env vars are resolved by shell/bash but when the container has no sh/bash how env vars will be resolved. I am running my app in K8S and the app is able o use env var from K8S. I wonder how this happened? Any idea?

muru avatar
us flag
What do you mean, "resolved by"?
celcin avatar
in flag
reading env var @muru
muru avatar
us flag
Environment variables are set by the parent process when creating a child process. They just exist in the child's memory - the child process is free to read them without the need for any shell
celcin avatar
in flag
@muru what/who is the parent process in this context then? I mean k8s start the container which is isolated from machine its running on.
muru avatar
us flag
But K8s knows your container definition and the env vars in the image, right? It can set those when starting the container.
celcin avatar
in flag
I wasn't aware of how this working behind the scene. I thought env var will be read by shell always. Thanks @muru
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.