Docker – How to unset environment variables from script

bashdockersupervisord

if I need to unset an environment variable from script it used to be "sourced" like

. ./myscript.sh

or

source ./myscript.sh

But how do i make this work, if i launch this script from supervisord?

[program:myapp]
command=source /usr/bin/myscript.sh
...

does not work.

Simple example script (myscript.sh):

#!/bin/bash
unset -v SOME_VAR

That's all …

Best Answer

You wouldn't generally /run/ a script by using source, instead you'd make it executable and then run it using it's path.

However, to specifically unset a variable just use unset:

$ TEST=foo
$ echo $TEST
foo
$ unset TEST
$ echo $TEST

$