containers / toolbox

Tool for interactive command line environments on Linux
https://containertoolbx.org/
Apache License 2.0
2.4k stars 208 forks source link

Easy environment customization #368

Open TheFrozenFire opened 4 years ago

TheFrozenFire commented 4 years ago

A common issue I'm finding amongst my various toolboxes is that I need to set up my environment variables differently depending on which toolbox I'm working out of. For instance, one toolbox may have a different distribution/version of a runtime like Java or PHP, and I need to point the runtime to the correct configuration paths for that particular version of the runtime.

Similarly, as a convenience function, it would be nice to be able to have my different toolboxes have different $GIT_HOME and $KUBECONFIG settings. I often have a toolbox for each "project" I'm working on, and those projects have a bunch of specific configuration.

This functionality could be accomplished by something as simple as a per-container bootstrap script that can be customized.

srbaker commented 4 years ago

I came here looking for the same thing! I need to set AWS_PROFILE depending on which toolbox I'm in.

HarryMichal commented 4 years ago

Thank you for mentioning this. I'm not sure if this is something Toolbox should do. The requested feature seems quite similar to what direnv does. But at the same time using direnv (used as an example; other tools could be used) requires it to be in every container? (not desired).

Just saying that, because I want to prevent reinventing the wheel if possible.

HarryMichal commented 4 years ago

Looking at this after some time I think the easiest option would be to expose some of the options of 'podman create' that work with environment variables. So when you create a new container you can set it any environmental variables you want. Does that sound ok @srbaker @TheFrozenFire?

TheFrozenFire commented 4 years ago

That would certainly be helpful, as long as the environment variables would override whatever is set in the parent environment.

HarryMichal commented 4 years ago

Could you be a bit more specific about that use case? I'm not that much familiar with env vars, so I can't really imagine such a scenario.

TheFrozenFire commented 4 years ago

A lot of tools use environment variables to configure their behaviour, both at a broad level (setting the config directory to use), or at a granular level (setting specific configuration options). If I could set the configuration directory that each of my tools use based on the toolbox I'm using, then simply by entering a toolbox my tools are configured appropriately for the project/client/infrastructure I'm working on.