singularity icon indicating copy to clipboard operation
singularity copied to clipboard

How to set env vars in containers via plugins

Open GodloveD opened this issue 5 years ago • 4 comments

Version of Singularity:

3.2.1

Expected behavior

It is straightforward to write a plugin that sets new environment variable(s) within the container at runtime.

Actual behavior

@AdamSimpson has provided feedback indicating that it is not straightforward to provide this functionality through a plugin.

Either an easy way already exist, but it requires better documentation or we need to develop one it seems.

Attn: @mem, @bauerm97

GodloveD avatar Jun 06 '19 18:06 GodloveD

I was able to hack around this by using an OCI spec generator to modify the OCI spec that's exposed from the plugins EngineConfig instance. To set ENV_VAR to VAL you can currently do something like this from within the plugin:

generator := generate.Generator{Config: &cfg.OciConfig.Spec}
envString := VAL
generator.AddProcessEnv("ENV_VAR", envString)

AdamSimpson avatar Jun 06 '19 19:06 AdamSimpson

Hello,

This is a templated response that is being sent out to all open issues. We are working hard on 'rebuilding' the Singularity community, and a major task on the agenda is finding out what issues are still outstanding.

Please consider the following:

  1. Is this issue a duplicate, or has it been fixed/implemented since being added?
  2. Is the issue still relevant to the current state of Singularity's functionality?
  3. Would you like to continue discussing this issue or feature request?

Thanks, Carter

carterpeel avatar May 15 '21 16:05 carterpeel

This issue has been automatically marked as stale because it has not had activity in over 60 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 14 '21 20:07 stale[bot]

@GodloveD Still getting this problem ? Have this been solved already ? If yes, what work around have you followed and applied ?

We're looking into the issue carefully, soon will bring to community and discuss ways to better solve as well address this. Thankyou for keeping the interest in the subject.

pedroalvesbatista avatar Jul 15 '21 23:07 pedroalvesbatista

Looks like a Hack was already documented so this old Singularity repo issue is being closed. If this is still critical, please open issue under new Apptainer repo.

kmuriki avatar Aug 16 '22 06:08 kmuriki