11

Could someone give me a brief explanation or links to an explanation of this topic? Info on the origination would be dandy. The only information that I could find is related to s6-overlay, which I have not yet used. Is this the origination of this?

of the use of this Shebang:

#!/usr/bin/with-contenv bash

vs. this Shebang:

#!/usr/bin/env bash

The second is what I use most of the time with bash.

The is a bash she-bang (shebang) question about a type of shebang.

#!/usr/bin/with-contenv bash
# your shellscript follows
#!/usr/bin/env bash
# this is my normal way of encoding the she-bang.

# Where to appropriately use?

I should note, that I did read "... just make use of with-contenv helper" and I was wondering if that is the first usage, or if it comes from another source like docker, w3c, or somewhere else.

5
  • 2
    A good place to start is to ask your operating system's package manager which package /usr/bin/with-contenv came from. If it says that it came from s6, then you know that the s6 documentation is authoritative. Commented Aug 3, 2019 at 22:38
  • 1
    ...indeed, honestly, that first part of the question is one you need to be answering yourself, because you're the only person here who's in a position to find out if you have the s6-overlay version of with-contenv or some completely unrelated program your friendly neighborhood sysadmin wrote and happened to give the same name. Commented Aug 3, 2019 at 22:40
  • 1
    I have no experience with it myself, but it seems to be explained here: github.com/just-containers/s6-overlay#container-environment
    – wjandrea
    Commented Aug 3, 2019 at 22:43
  • 1
    Even easier that using your package manager, open the file up in your editor of choice. Does it look like the s6-overlay version of with-contenv? If so, then yes, it's the s6 version. Commented Aug 3, 2019 at 22:43
  • To be clear -- bash doesn't read your shebang, no matter what its value is, so this is only tangentially a question about bash. The shebang is read by your operating system when deciding what program to run; if you run /usr/bin/env bash, then the OS invokes /usr/bin/env, and tells it to find a version of bash to run. If you use #!/usr/bin/with-contenv bash, then the OS invokes /usr/bin/with-contenv, which presumably as its next argument takes the name of a program to run after doing... something. What that something is depends on what with-contenv is on your system. Commented Aug 3, 2019 at 23:14

1 Answer 1

19

Indeed, this is related, and very specific, to the s6-overlay architecture. This is a tool for using the s6 process supervisor inside of Docker containers.

In some more detail, Docker is otherwise not well-suited to running multiple services and daemons in the same container, and the general architecture of a supervisor is at odds with how Docker wants things. s6-overlay attempts to fix this, so that you can run services inside of a single Docker container.

As explained in the documentation, with-contenv is a wrapper which makes sure the argument is run with the environment variables specific to s6-overlay.

Concretely, it uses s6-envdir to load the environment from /var/run/s6/container_environment before executing its argument (in this case, bash).

1
  • 2
    Extra historical context, s6 is essentially a few minor (but important) improvements over runit, and runit is a supervision suite that really integrates the daemontools philosophy of service supervision into debian. And daemontools originated the idea of envdir Commented Nov 6, 2022 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.