- Newest
- Most votes
- Most comments
The AWS documentation indicates that the environment variables are passed in through the docker run --env
invocation. This leads me to believe that the answer to your question might be on the docker side.
I was looking for something similar and found this conversation, it may apply to your situation here: https://github.com/moby/moby/issues/15383#issuecomment-128748669
Essentially, the USER
directive is not expected to have an impact on which environment variables are accessible from the docker side.
Are you doing anything with sudo
?
As a general rule, the USER directive will not have any impact on your environment variables.
Environment variables in Linux are inherited by each process from its parent process. This happens automatically unless something specifically overrides this behavior.
Here are some things to check:
- Have you confirmed that the environment variables are visible to the root user?
- Are you (or the service you're starting) employing any special privilege dropping or security practices that might be intentionally filtering environment variables?
- Are you following the "One Process per Container" best practice for Docker containers? (If not, this can make it harder to troubleshoot this kind of problem.)
- In your Dockerfile, are you introducing any wrappers or startup commands that might be creating an overly-complex process tree? (This would increase the chances that some environment variables are being swallowed by a layer of indirection or security.)
If all else fails, run the container locally and inspect the process environments directly (on the host) by checking /proc/$PID/environ. You can see where the environment variables are getting stripped by looking in there.
Relevant content
- Accepted Answerasked 2 years ago
- Accepted Answerasked 3 months ago
- asked 10 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago