Get Environment Variable from Docker Container

后端 未结 10 1972
花落未央
花落未央 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:53

    We can modify entrypoint of a non-running container with the docker run command.

    Example show PATH environment variable:

    1. using bash and echo: This answer claims that echo will not produce any output, which is incorrect.

      docker run --rm --entrypoint bash  -c 'echo "$PATH"'
      
    2. using printenv

      docker run --rm --entrypoint printenv  PATH
      

提交回复
热议问题