React cannot read passed args from docker in runtime

  docker, reactjs

I have a react application where I want to access to docker args passed when using the CLI like the following:

docker container run -it -p 3001:80 --env MYENV=MYENV myimage

and in my react app just consume it, I have tried the following in my dockerfile:

ARG MYENV
ENV MYENV ${MYENV}

but this works only in build time and not in runtime, any idea?

Source: Docker Questions

LEAVE A COMMENT