我创建了一个如下所示的 Dockerfile:
FROM consul
COPY config-file.json /consul/config
ENTRYPOINT ["consul", "agent, "-config-file=/consul/config/config-file.json"]
配置(config-file.json)文件如下所示:
{
"datacenter": "microservices",
"data_dir": "/opt/consul",
"log_level": "INFO",
"disable_host_node_id" : true,
"server": true,
"bootstrap_expect" : 2,
"client_addr": "0.0.0.0",
"ui": true,
"bind_addr": "192.168.70.20"
}
然后运行容器并得到以下结果:
dockerizer@docker1:~/consul$ docker run --rm -ti --network=host servery
/bin/sh: syntax error: unterminated quoted string
我做错了什么?
最佳答案
您在 ENTRYPOINT 中的“代理”一词后面缺少引号。
ENTRYPOINT ["consul", "agent", "-config-file=/consul/config/config-file.json"]
缺少引号是导致未终止引号消息的原因,因此计算或执行的 ENTRYPOINT 显示为 consul agent "-config-file=/consul/config/config-file.json
(这是缺少报价)
关于docker - dockerfile 中语法错误未终止的带引号的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46951090/