Re: Very basic question, regarding redirects

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Mon, 11 May 2015 15:11:44 +0200

On 11/05/2015 13:52, Scott Mebberson wrote:
> I'm working on an addition to the s6-overlay project. I want to make it
> super easy to create environment variables within a Docker container.

  IIRC, /var/run/s6/container_environment is meant to hold the variables
that the container is actually started with; outside interaction with
the container may rely on that (i.e. commands started with "with-contenv"
may not work correctly if that environment has been modified). I'm not
sure it's safe to do that.

  But if that's what you want, you can just type

  redirfd -w 1 /var/run/s6/container_environment/env_var_name
  s6-echo -- env_var_value

and you're done. I'm not sure it justifies a specific script to
do that, unless you want to add some more processing.

  Be aware that "with-contenv" reads the environment variables
verbatim from the files, so you have to manually strip newlines and
otherwise sanitize env_var_value before storing it.


> tr "a-z" "A-Z"

  You can't do that in the overlay, because there's no guarantee
that every image will have a "tr" binary. That's the reason why
everything in the overlay is written in execline and uses
s6-* binaries: no external dependencies at all, so it works with
every possible image.
  Just trust the user to use the correct filename. Also, it is valid
to use lowercase in environment variables - upper case is just a
convention used to work around a deficiency of the shell, i.e. treating
internal shell variables and environment variables the same way (which
makes it harder to tell the difference, that's why people usually
reserve full upper case for the environment).


> But I can't get it to work. I guess redirection isn't supported? I've got
> no idea really, I'm lost!

  http://skarnet.org/software/execline/redirfd.html :)

  Good luck,

-- 
  Laurent
Received on Mon May 11 2015 - 13:11:44 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC