Get Environment Variable from Docker Container

后端 未结 10 2006
花落未央
花落未央 2020-12-12 11:12

What\'s the simplest way to get an environment variable from a docker container that has not been declared in the Dockerfile?

For instance, an environment v

10条回答
  •  生来不讨喜
    2020-12-12 11:42

    None of the above answers show you how to extract a variable from a non-running container (if you use the echo approach with run, you won't get any output).

    Simply run with printenv, like so:

    docker run --rm  printenv 
    

    (Note that docker-compose instead of docker works too)

提交回复
热议问题