Is it possible to add environment variables to a crashed container?
I tried
$ docker start --env MYVAR='value' <container_id>
$ docker exec --env MYVAR='value' <container_id> entrypoint.sh
But it didn't work
Is it possible to add environment variables to a crashed container?
I tried
$ docker start --env MYVAR='value' <container_id>
$ docker exec --env MYVAR='value' <container_id> entrypoint.sh
But it didn't work
You can't change environment variables on a container (or any other process) after it's been created.
I wouldn't bother trying to recover a container that's exited. docker rm
it and docker run
a new one. When you do docker run
the new container, you can add or change environment variables as needed.
docker start doesn't have an --env
option, it only starts a stopped container.
docker exec does allow setting environment variables when running a command on your container using the --env
option.
Note that environment variables are also set when calling docker run to create the container with the --env
option.