如何通过docker-compose.yml中多行环境变量
我正在尝试转换此 docker run命令:
docker run -it --rm --name logstash --net test opensearchproject/logstash-oss-with-opensearch-output-plugin:7.16.2 -e 'input { stdin { } } output {
opensearch {
hosts => ["https://opensearch:9200"]
index => "opensearch-logstash-docker-%{+YYYY.MM.dd}"
user => "admin"
password => "admin"
ssl => true
ssl_certificate_verification => false
}
}'
到docker-compose.yml文件。但是,我不知道如何定义上面传递的环境配置。关于如何将无名的多行环变量传递给码头组合的任何建议吗?
我尝试了多种YAML多行格式,但我不断获得:
错误:环境变量名称'input {stdin {}} output {openSearch {hosts'可能不会 包含空格。
docker-compose.yml:
version: '3'
services:
logstash-producer:
image: opensearchproject/logstash-oss-with-opensearch-output-plugin:7.16.2
container_name: logstash-producer
environment:
- 'input { stdin { } } output {
opensearch {
hosts => ["https://opensearch:9200"]
index => "opensearch-logstash-docker-%{+YYYY.MM.dd}"
user => "admin"
password => "admin"
ssl => true
ssl_certificate_verification => false
}
}'
I am trying to convert this docker run command:
docker run -it --rm --name logstash --net test opensearchproject/logstash-oss-with-opensearch-output-plugin:7.16.2 -e 'input { stdin { } } output {
opensearch {
hosts => ["https://opensearch:9200"]
index => "opensearch-logstash-docker-%{+YYYY.MM.dd}"
user => "admin"
password => "admin"
ssl => true
ssl_certificate_verification => false
}
}'
to a docker-compose.yml file. However I can't figure out how to define the environment config passed above. Any suggestions on how to pass nameless multiline environment variable to a docker-compose?
I tried multiple yaml multiline formats, but I keep getting:
ERROR: environment variable name 'input { stdin { } } output { opensearch { hosts ' may not
contain whitespace.
docker-compose.yml:
version: '3'
services:
logstash-producer:
image: opensearchproject/logstash-oss-with-opensearch-output-plugin:7.16.2
container_name: logstash-producer
environment:
- 'input { stdin { } } output {
opensearch {
hosts => ["https://opensearch:9200"]
index => "opensearch-logstash-docker-%{+YYYY.MM.dd}"
user => "admin"
password => "admin"
ssl => true
ssl_certificate_verification => false
}
}'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于
-e
位是在图像名称之后出现的,因此它是容器的命令。我从来没有这样做,也无法测试它,但是
如果那不起作用,请尝试将命令全部放在一行上。
Since the
-e
bit comes after the image name, it's a command for the container.I've never done this and I'm unable to test it, but try this
If that doesn't work, I'd try putting the command all on one line.