I'm using command docker run -e GRB_WLSACCESSID=xxxxxxx
to set environment variables for Gurobi authorization. The OS of container is Ubuntu 16.04. This is OK if I login the container via SSH interactively and read the environment variables by python code os.getenv()
.
But, when I add this container as remote SSH interpreter in Pycharm and execute the python code along Pycharm, I can't get the environment variables.
At last I found the problem is that the environment variables generated by docker run -e
can only be read by interactive shell. This can be validated by executing ssh root@x.x.x.x env
, and interactively execute env
after logging into the container. The former outputs less.
One possible solution is write some configuration manually after the container is generated, e.g., set the variables in /etc/environment
(provided by this).
The other possible solution is add the variables manually in Pycharm edit configuration
.
Is there a more elegant solution? :(