Reputation: 197
I have a docker container on a service that I can't start or modify myself. I need to add a few more environment variables to it. I can access to it, and do some docker exec inside it, once it is running. But exec is ephemeral.
I was wondering, is there a way to override/add/update a docker container variables while it is running? Or maybe stop, update and run the container by its name again?
Thank you, Have a great day!
Upvotes: 0
Views: 826
Reputation: 159810
You can't change this without deleting and recreating the container.
At a Unix level, a process's environment variables are fixed once the process starts. The process can change its own environment but nothing else can; if a process launches child processes, the parent can specify the childrens' initial environments, but once they start it can't modify them further.
At a Docker level, the "parent" process for this becomes the Docker daemon. So you can specify the main container process's initial environment (through e.g. docker run -e
flags), but once the container's started, you can't change that environment any further.
Upvotes: 1