1

I have a docker container with a environment variable that I want to change on restart time. I have read about the -e option that can be used for that in docker run command (described for instance here).

I have tried to use it with restart:

sudo docker restart 1db2df40d98c -e FOOBAR_VERSION='v1'

However, I get this error:

unknown shorthand flag: 'e' in -e
See 'docker restart --help'.

I have also read about re-building the container with the new environment variable value. However, I'd like to avoid so overhelming alterantive. I just want to restart the container, but with a different environment variable value at starting time.

Any hint/reference/help regarding this problem is really welcome, please.

EDIT: I have also tried doing the restart in two steps, I mean:

sudo docker stop 1db2df40d98c
sudo docker start 1db2df40d98c -e FOOBAR_VERSION='v1'

But the result is the same.

fgalan
  • 11,732
  • 9
  • 46
  • 89
  • docker restart does not take that option, as you've seen. Not an answer because I've only glanced at it, but "DockerFile" is sort of like an alias which might get you what you want. –  May 10 '18 at 16:41
  • Have you made changes to the container after you started it -- is that why you don't want to rebuild it? If so, you could define those changes within docker-compose configuration, the Dockerfile, or the entrypoint script to make it easier to rebuild, and include the env variables there. – Valerie Parham-Thompson May 10 '18 at 18:15

0 Answers0