首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在docker运行中将命令行参数作为环境变量传递?

如何在docker运行中将命令行参数作为环境变量传递?
EN

Stack Overflow用户
提问于 2020-12-16 14:59:50
回答 1查看 74关注 0票数 0

我有一个docker镜像bcgovimages/aries-cloudagent:py36-1.14-1_0.5.1,为了运行它,我给出了以下命令:

代码语言:javascript
复制
docker run -d -p 5001:5000 -p 10001:10000 --name postgrearies1 bcgovimages/aries-cloudagent:py36-1.14-1_0.5.1 start -it http 0.0.0.0 10000 -ot http --admin 0.0.0.0 5000 --admin-insecure-mode --seed 10000000000000000000111111111110 --wallet-type indy --log-level debug --storage-type indy --wallet-storage-type postgres_storage --wallet-name test2 --wallet-storage-config "{\"url\":\"xx.xx.xxx.xxx:5432\",\"wallet_scheme\":\"DatabasePerWallet\"}" --wallet-storage-creds "{\"account\":\"xxx\",\"password\":\"xxxx\",\"admin_account\":\"postgres\",\"admin_password\":\"xxxxx\"}"

我希望将--wallet-storage-config--wallet-storage-creds作为环境变量进行传递。如何从将--wallet-storage-config和--wallet-storage-creds作为环境变量而不是命令行参数的bcgovimages/aries-cloudagent:py36-1.14-1_0.5.1创建新映像?

EN

回答 1

Stack Overflow用户

发布于 2020-12-16 15:40:16

您可以在Dockerfile中使用${...}。使用-e描述docker run操作的环境变量。

Dockerfile

代码语言:javascript
复制
FROM bcgovimages/aries-cloudagent:py36-1.14-1_0.5.1 

ENTRYPOINT start -it http 0.0.0.0 10000 -ot http --admin 0.0.0.0 5000 --admin-insecure-mode --seed 10000000000000000000111111111110 --wallet-type indy --log-level debug --storage-type indy --wallet-storage-type postgres_storage --wallet-name test2 --wallet-storage-config ${WALLET_STORAGE_CONFIG} --wallet-storage-creds ${WALLET_STORAGE_CREDS}

代码语言:javascript
复制
docker run -d -p 5001:5000 -p 10001:10000 -e WALLET_STORAGE_CONFIG="{\"url\":\"xx.xx.xxx.xxx:5432\",\"wallet_scheme\":\"DatabasePerWallet\"}" -e WALLET_STORAGE_CREDS="{\"account\":\"xxx\",\"password\":\"xxxx\",\"admin_account\":\"postgres\",\"admin_password\":\"xxxxx\"}" --name postgrearies1 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65318621

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档