當前使用Elastic Beanstalk運行Docker容器,我需要將重要信息作爲環境變量傳遞到我的容器。將環境變量傳遞給Docker容器
我現在Dockerrun.aws.json看起來是這樣的:
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "b2boost/rabbitelasticdockstash",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "80"
}
],
"environment": [
{
"name": "RABBITMQ_HOST",
"value": "RABBITMQ_HOST"
},
{
"name": "RABBITMQ_PASSWORD",
"value": "RABBITMQ_PASSWORD"
},
{
"name": "RABBITMQ_USER",
"value": "RABBITMQ_USER"
},
{
"name": "RABBITMQ_VHOST",
"value": "RABBITMQ_VHOST"
},
{
"name": "ELASTICSEARCH_HOST",
"value": "ELASTICSEARCH_HOST"
},
{
"name": "ELASTICSEARCH_PASSWORD",
"value": "ELASTICSEARCH_PASSWORD"
},
{
"name": "ELASTICSEARCH_PORT",
"value": "ELASTICSEARCH_PORT"
},
{
"name": "ELASTICSEARCH_PROTOCOL",
"value": "ELASTICSEARCH_PROTOCOL"
},
{
"name": "ELASTICSEARCH_USER",
"value": "ELASTICSEARCH_USER"
}
],
"Volumes": [
],
"Logging": "/var/log/eb-activity.log"
}
然而,這並不工作。當ssh方式連接到我的豆莖實例,然後獲取環境變量的內容,我可以看到他們未初始化:
[[email protected] ~]$ sudo docker exec goofy_curie env
PATH=/opt/logstash/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:bin
HOSTNAME=HOSTNAME
LANG=C.UTF-8
JAVA_VERSION=7u79
JAVA_DEBIAN_VERSION=7u79-2.5.5-1~deb8u1
LOGSTASH_MAJOR=1.5
LOGSTASH_VERSION=1:1.5.1-1
HOME=/root
如何設置環境變量在我的容器? Dockerrun.aws.json似乎不適合我。
你試試這個選項:http://stackoverflow.com/questions/28298101/elastic-beanstalk-environment-variables爲碼頭主人? –
如果您不希望將信息保留在VCS上,則可以使用Web控制檯。它適用於我的dockerized環境。 http://stackoverflow.com/a/17878600/1102395 – Samar