Reputation: 2603
There are ways to pass the environment variable declared in dockerfile using the docker run
command using --env
or -e
options.
E.g. Lets say you are using MAC or linux, then you can define a shell variable like below:
export MyEnvVar=SomeValue
And then pass this value to an environment variable that was defined inside your dockerfile.
docker run --name "MyContainerName" -e MyEnvVar Container_Image_Name
And for this to work you must have a statement in the dockerfile like below:
ENV MyEnvVar=${MyEnvVar}
However, I do not want to define any variable inside dockerfile but add a new environment key/value while creating a container instance using docker run
or some other way.
So is there a way to add a new environment variable using docker run
or by some other means in to a docker container without declaring that environment variable in dockerfile?
Upvotes: 1
Views: 866