Bootstrap FreeKB - Docker - Define environment variables in a container using the docker run -e or --env command
Docker - Define environment variables in a container using the docker run -e or --env command

Updated:   |  Docker articles

This assumes you have installed Docker on Linux and Docker is running.

When creating a container using the docker run command the -e or --env option can be used to define environment variables that will be set in the container. 

sudo docker run --env foo=bar --name my-container my-image:latest

 

Of if the container already exists the docker update command can be used.

sudo docker update --env foo=bar my-container

 

You can use the docker inspect command to view the JSON for the container.

~]$ sudo docker inspect my-container | jq .[].HostConfig.ExtraHosts
foo.example.com:172.16.0.2

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter f42e3d in the box below so that we can be sure you are a human.