你好!经过深入研究,我决定将这个问题提交给社区。不久前我开始学习 docker & docker-compose。
我的问题是:
如何在控制台中获取可能的环境变量列表。它们列在 docker hub 上,但是如果从图像本身中获取,我该如何获取?例如,图像nextcloud在网站上列出了这个环境变量:
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"
]
这比集线器上列出的要重要得多。我怎样才能得到这些变量?
Docker 不会知道的。例如,如果我制作了一个脚本,上面写着:
并将其打包在一个容器中,docker 包装中没有任何内容需要您告诉 docker,
$SUPER_SECRET_VAR
并且由于 docker 可以打包用多种语言编写的应用程序,因此没有通用的方法来解析每个可能的应用程序来提取它。你剩下: