duramen
duramen

Reputation: 91

How to get all available environment-variables of docker image?

I want to get all the environment-variables available in the docker image for easy configuration at startup.

For example, when the elasticsearch image is started, the xpack.security.enabled variable can be added, etc.

docker run -d -p 9200:9200 --name=elasticsearch-6.5.4 -e xpack.security.enabled=false elasticsearch:6.5.4

How to know what other variables can be configured in this image, as shown in the help documentation?

thank you very much!

Upvotes: 9

Views: 8889

Answers (3)

Nick Dong
Nick Dong

Reputation: 3736

Let's say the image, zookeeper:3.8.0.

  1. you could use command docker inspect --format '{{ .Config.Env }}' zookeeper:3.8.0 | column -t -s ' '
[myuser@myhost zookeeper]$ docker --version
Docker version 19.03.5, build 633a0ea838
[myuser@myhost zookeeper]$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
zookeeper           3.8.0               d3d4daa1366e        7 days ago          279MB
[myuser@myhost zookeeper]$ docker inspect --format '{{ .Config.Env }}' zookeeper:3.8.0 | column -t -s ' '
[PATH=/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/apache-
zookeeper-3.8.0-bin/bin  JAVA_HOME=/usr/local/openjdk-11  LANG=C.UTF-8  
JAVA_VERSION=11.0.15  ZOO_CONF_DIR=/conf  ZOO_DATA_DIR=/data  
ZOO_DATA_LOG_DIR=/datalog  ZOO_LOG_DIR=/logs  ZOO_TICK_TIME=2000  
ZOO_INIT_LIMIT=5  ZOO_SYNC_LIMIT=2  ZOO_AUTOPURGE_PURGEINTERVAL=0  
ZOO_AUTOPURGE_SNAPRETAINCOUNT=3  ZOO_MAX_CLIENT_CNXNS=60  
ZOO_STANDALONE_ENABLED=true  ZOO_ADMINSERVER_ENABLED=true  ZOOCFGDIR=/conf]

--format DOC

  1. And also see commands list of zookeeper:3.8.0 on docker hub

  2. And you should see enviroment variables of zookeeper image on docker hub image description

  3. see Dockerfile on github

  4. you should see the built-in enviroment of zookeeper from zookeeper doc.


For elasticsearch, there don't seem to be that many configuration items defined by the docker image.

[myuser@myhost zookeeper]$ docker inspect --format '{{ .Config.Env }}' elasticsearch:6.5.4
[PATH=/usr/share/elasticsearch/bin:/usr/local/sbin:/usr/local/bin:/us
r/sbin:/usr/bin:/sbin:/bin  ELASTIC_CONTAINER=true  
JAVA_HOME=/opt/jdk-11.0.1]

So, you should see the official doc of elasticsearch.

Upvotes: 2

Nollymar Longa
Nollymar Longa

Reputation: 139

docker image inspect {image_name} has a section called "Env" where you can see this info.

Upvotes: 7

Shashank V
Shashank V

Reputation: 11193

It depends on the image. You need to check documentation of the image.

Upvotes: 0

Related Questions