I have a docker-compose that has
myimage:
image: myimage:latest
environment:
MY_VAR: "something"
the container uses MY_VAR internally, and sometimes in automated testing I'd like to restart that specific container with a different MY_VAR (to simulate a process restart with different environment variable settings)
Is there a way to do this while keeping the rest of the docker-compose container up?
Like @robin.thoni said, would need to recreate the container to change the MY_VAR
value, but you could make the process simpler by using a environment var in the compose YML, like this:
myimage: image: myimage:latest environment: - MY_VAR: ${A_ENV_VAR}
And running the container like this:
A_ENV_VAR=test docker-compose run myimage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With