Here we will learn how to set environment variables for docker container in windows with example or how to pass environment variables to existing / running docker container in windows with example or add environment variables to existing docker container in windows with example. By using “–e” flag we can easily pass or set environment variables for existing or running docker container in windows.
In previous articles I explained asp.net core mvc web api tutorial with example, asp.net web api insert data into database with example, asp.net download multiple files as zip folder with example, asp.net mvc compare passwords validation with example, read data from msword file in asp.net with example, create / read / delete cookies in asp.net website with examples, Different types of constructors in c#, vb.net, destructor in c#, vb.net with examples and many more articles related to in asp.net, mvc, c#, vb.net. Now I will explain how to add environment variables for docker container with example.
By using docker I created container in windows after that I got requirement like need to add environment variables for existing container for that I wrote script by using “-e” flag like as shown below
docker run -d -t -i -e environment_variable container_name
In above syntax we need to replace environment_variable with your required variable name and container_name with your containerid
Following is the example of setting environment variable for docker container in windows.
docker run -d -t -i -e KAFKA_ADVERTISED_HOST_NAME = 'staging' container_name