Hi Team, i am deploying a React app env file stored at /usr/share/nginx/html/environment_varibles.js file I replacd that value while building a docker image. its working fine but, while running that image as container i want to change that env parameter value.
Your approach to set an environment in the image, and override it for the container is correct. And it is exactly what you do! Nothing more, nothing less.
Though, your expectation that it would do anything on it’s on is incorrect. If you docker exec into your container, and type echo ${REACT_ADD_DOMAIN}, you will see it worked.
If you want to modify a file based on the value of the environment variable, then you need to create an entrypoint script and implement that logic to actually modify the file (make sure to run nginx at the end of your script; exec nginx -g daemon off;), copy the script into the image (make it executable if necessary) and then declare it as ENTRYPOINT.
As @meyay explained it sets the variable in the container and you could indeed create an entrypoint, however, since you actually used the ARG instruction which sets the default value of a build argument, you can change the file by rebuilding the image with an overridden argument:
Note: Using code blocks (</> button) make your post much readable instead of sharing images or inserting commands with links that will be interpreted by the forum
You should invest more time in learning instead of changing a RUN instruction to be an entrypoint. This is not what an entrypoint should be and doesn’t make sense at all. I shared an almost “copy-paste” solution with you which doesn’t require changing the Dockerfile and you have chosen to change the Dockerfile although it seems you know nothing about the entrypoint instruction. If you search for it you will find plenty of blog posts but you can also read the documentation:
I expected a solution and root cause How ever I resolved that issue by adding CMD in that CMD added sed expression. I got an expected output. Thanks for your response.