Docker 获取可能的环境变量列表

Docker 获取可能的环境变量列表

你好!经过深入研究,我决定向社区提出这个问题。不久前我开始学习docker和docker-compose。

我的问题是:
如何在控制台中获取可能的环境变量列表。它们在 docker hub 上列出,但我如何从镜像本身获取它们?例如,镜像下一个云已在网站上列出了此环境变量:

PostgreSQL:

POSTGRES_DB Name of the database using postgres.
POSTGRES_USER Username for the database using postgres.
POSTGRES_PASSWORD Password for the database user using postgres.
POSTGRES_HOST Hostname of the database server using postgres.
If you set any values, they will not be asked in the install page on first run. With a complete configuration by using all variables for your database type, you can additionally configure your Nextcloud instance by setting admin user and password (only works if you set both):

NEXTCLOUD_ADMIN_USER Name of the Nextcloud admin user.


  NEXTCLOUD_ADMIN_PASSWORD Password for the Nextcloud admin user.
    If you want, you can set the data directory, otherwise.......
.................................................................

但当我这样做

docker inspect nextcloud |  jq '.[] | .Config.Env'

我只得到这个:

[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "PHPIZE_DEPS=autoconf \t\tdpkg-dev \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkg-config \t\tre2c",
  "PHP_INI_DIR=/usr/local/etc/php",
  "APACHE_CONFDIR=/etc/apache2",
  "APACHE_ENVVARS=/etc/apache2/envvars",
  "PHP_EXTRA_BUILD_DEPS=apache2-dev",
  "PHP_EXTRA_CONFIGURE_ARGS=--with-apxs2 --disable-cgi",
  "PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
  "PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
  "PHP_LDFLAGS=-Wl,-O1 -pie",
  "GPG_KEYS=42670A7FE4D0441C8E4632349E4FDC074A4EF02D 5A52880781F755608BF815FC910DEB46F53EA312",
  "PHP_VERSION=7.4.22",
  "PHP_URL=https://www.php.net/distributions/php-7.4.22.tar.xz",
  "PHP_ASC_URL=https://www.php.net/distributions/php-7.4.22.tar.xz.asc",
  "PHP_SHA256=8e078cd7d2f49ac3fcff902490a5bb1addc885e7e3b0d8dd068f42c68297bde8",
  "PHP_MEMORY_LIMIT=512M",
  "PHP_UPLOAD_LIMIT=512M",
  "NEXTCLOUD_VERSION=22.0.0"
]

这比中心上列出的内容重要得多。我如何才能获取这些变量?

答案1

Docker 不会知道这一点。例如,如果我编写了一个脚本,内容如下:

#!/bin/sh

if [ -n "$SUPER_SECRET_VAR" ]; then
  echo "Super secret mode enabled"
else
  echo "Hello world"
fi

并将其打包到容器内部,docker 打包中不需要您告知 docker 任何内容$SUPER_SECRET_VAR,而且由于 docker 可以打包用多种语言编写的应用程序,因此没有通用的方法来解析每个可能的应用程序来提取它。

你剩下:

  1. 阅读有关图像/应用程序的文档。
  2. 阅读脚本,特别是入口点脚本。
  3. 阅读代码。

相关内容