Environment variables missing
Hello,
I am creating a pod with environment variables, but it doesn't seem to work. When I connect via SSH, and echo $ENV_VAR_NAME it prints nothing.
Am I missing something?
Also, printenv doesn't show the default environment variables from runpod, nor my added environment vars.
I am using my own template, but the Docker image is build on top of an official runpod image.
Solution:Jump to solution
Its docker yeah, environment in linux is per user i guess, so when you login using ssh, your env's wont be there because the docker container starts your application as a different user
6 Replies
I already checked the following issues, but that did not solve my issue:
- https://discord.com/channels/912829806415085598/1191734950660153414
- https://discord.com/channels/912829806415085598/1195693903744090184
Try recreating the pod, how are you connecting to ssh?
try checking via web terminal if your key is there
Unless you're accessing on your main user like from ENTRYPOINT or CMD, your env's arent there
I already tried with multiple pods, but get the same result. I create everything via web terminal, and the key are visible in the web terminal.
Oh, I do not understand what this means, but I guess that's my issue? I connect via the ssh command given on the website when I create a new pod
Ah, you mean I should access them via a script that is ran automatically by CMD?
I will try that and let you know if it solves my issue.
Solution
Its docker yeah, environment in linux is per user i guess, so when you login using ssh, your env's wont be there because the docker container starts your application as a different user
Yes, or re export it again
printenv | awk -F = '{ print "export " $1 "="" $2 """ }' >> /etc/rp_environment
echo 'source /etc/rp_environment' >> ~/.bashrc
That helps automatically exporting all env variables
I added "env > saved_env_var.txt" in my start.sh file, and the txt file contains everything that was missing, so it should solve my issue.
Thank you very much!