For example, if inside docker
container I create a variable as -
/# token="dsfgkd-sdasdas-fas3ad-ssssad"
exit
root@testvm:~# echo $token
//how to get the result..?
root@testvm:~#
For example, if inside docker
container I create a variable as -
/# token="dsfgkd-sdasdas-fas3ad-ssssad"
exit
root@testvm:~# echo $token
//how to get the result..?
root@testvm:~#
Containers are isolated from the host, but the host can connect inside the container
If you create your variable and export it, it will be available for your container and the connections coming from a
docker exec -it container_name_or_id bash
or
docker exec -it container_name_or_id echo $token
you can see the environment variables in your container with
docker exec -it container_name_or_id env
if you just create it in your process, it will be available for your process only
The ENV directive in a Dockerfile is designed for creating ernvironment variables at build time
see the doc
https://docs.docker.com/engine/reference/builder/#env
At run time, you have
docker run -e
extract from
https://docs.docker.com/v1.11/engine/reference/run/
docker run -e "deep=purple" --rm ubuntu /bin/bash -c export
and
docker run --env-file
see from
https://docs.docker.com/engine/reference/commandline/run/
--env-file Read in a file of environment variables