Docker does not support /etc/environment. it only looks for env vars in the user environment. (I tried).
When I want to set the default path to my compose file using the docker supported COMPOSE_FILE env variable, I need to use the EXPORT command as current user (without sudo). This works.
I would like to know where the file is located, with vars stored via the EXPORT command?
I looked in several locations mentioned in the Arch Wiki, none of them exist. Even checked locations for systemd.
It will be either ~/.bash_profile (if you use bash) or ~/.zprofile (if you use zsh). Both files should exist in every recent-enough installation, but if they don’t, then it’s easy to create them.
The .bashrc file also exist but contains code, no variables.
It’s a bit mysterious…
I see similar questions on the forum and lots of references to Arch Wiki, but that does not seem to apply.
Sorry I don’t understand.
When I do printenv, I see my exported variables. So they are already stored somewhere?
Should I literally add “export” at the bottom of the ~/.bash_profile file? And then run the command again to add those envs? Will I not end up with double variables?
EDIT: OK now it makes sense: closing the terminal and reopening: my docker-compose command can no longer find its config. The export command only exists during the life of the shell I am in.
In conclusion, I should simply add my env variables to the ~/.bash_profile file, not via the export command.
In memory, yes. What sets them is another matter. There are various files under /etc/profile.d that set environment variables.
Yes. Either one of the two approaches below will do.
VARIABLE=value
export VARIABLE
… or…
export VARIABLE=value
For exporting a bash shell function, you need to use the -f command option…
export -f name-of-function-here
If you want it to become active in your current login session, then yes. ~/.bash_profile is only read upon logging in.
There is no such thing, because variable names are unique. At most you can replace a variable’s value by reassigning it.
export will — as its name says — set a variable (and its value) and export it to all subshells started from the same shell. So if you set a variable without exporting it, then it’ll only apply to the current shell, and not to a subshell, but if you export the variable, then every subshell from the current environment will inherit the variable and its value.
However, in order to make a variable permanent — with or without that it’s being exported — you need to define it in one of the files that are being sourced into your environment. Traditionally in UNIX, this would be the file ~/.profile, but the bash that ships with Arch doesn’t by default read ~/.profile. Instead, it uses ~/.bash_profile.