I want to use one docker image for all environments(build once deploy anywhere) and pass env vars when i run the container on test,qa,prod servers,i'm afraid if for eg devs are merging prs with new features to test branch then a new image is built and published to registry, does this in any way affect the image used for production and qa? Even if the containers were stopped and run again or image repulled? What can be done in this case?
One docker image for all environments, and run containers with environment variables
example_image
/example_image:latest
Yes, prod and qa will be affected by the image update.
example_image
/example_image:latest
Prod and qa will be affected by the image update only when you pull new image from the registry explicitly (if no configuration to pull image on each run automatically)
example_image_test:latest/example_image:test
, prod uses example_image_prod:latest/example_image:prod
( So they use the same image by nature but with different names. It is better practice than the options above )
No, the prod won't be affected by the change of test image until you update prod image explicitly too.