英文:
Docker-compose - facing error while starting container after adding logging option
问题
我们的Docker版本是20.10.21,构建版本是baeda1f。在docker-compose.yml中没有指定日志选项时,它可以正常运行,但是当我们指定日志选项并启动docker-compose时,它会抛出错误“ERROR: for
这是docker-compose.yml中该服务的条目 -
logging:
driver: "json-file"
options:
max-file: 5
max-size: 10m
请告诉我我们的配置可能有什么问题。感谢您的帮助。
英文:
We have Docker version 20.10.21, build baeda1f. It is running fine without logging options in docker-compose.yml but when we specify the logging options and then start docker-compose, it throws an error
"ERROR: for <servicename> Cannot create container for service <servicename>: json: cannot unmarshal number into Go struct field LogConfig.HostConfig.LogConfig.Config of type string"
This is the entry in docker-compose.yml under that service -
logging:
driver: "json-file"
options:
max-file: 5
max-size: 10m
Please let me know what might be wrong with our configuration. Appreciate your help.
答案1
得分: 5
原来我必须将 max-file 指定为字符串。四年前已经有人提出了这个问题,并自己找到了答案。
链接:https://stackoverflow.com/questions/54939953/docker-bjson-cannot-unmarshal-number-into-go-struct-field-logconfig-config-of
logging:
driver: "json-file"
options:
max-file: "5"
max-size: 10m
希望对某人有所帮助。
英文:
Turned out that I had to specify max-file as string. It was already asked by someone 4 years ago, who found the answer himself.
https://stackoverflow.com/questions/54939953/docker-bjson-cannot-unmarshal-number-into-go-struct-field-logconfig-config-of
logging:
driver: "json-file"
options:
max-file: "5"
max-size: 10m
Hope it helps someone.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论