如何编写要在docker compose中执行的命令?
我对 docker 和 docker compose 有点陌生。我使用的是 20.10.12 版本的 docker 和 2.9.0 版本的 portainer。我的目标是为elasticSearch做docker compose,将其部署在portainer中,但我遇到一个问题,即给定的内存不够。查看其他问题后,我发现我可以执行以下 bash 命令来为虚拟机内存分配更大的限制
sysctl -w vm.max_map_count=262144
所以我的 .yml 是这样的:
version: "3.8"
services:
command: >
bash -c ' sysctl -w vm.max_map_count=262144'
master1:
image: docker.elastic.co/elasticsearch/elasticsearch:8.0.0
environment:
node.name: "master1"
ulimits:
memlock:
soft: -1
hard: -1
deploy:
endpoint_mode: dnsrr
mode: "replicated"
replicas: 1
resources:
limits:
memory: 4G
问题是,当我尝试部署此组合时,它显示“services.command”必须是一个映射”。
我认为当缩进不正确时就会出现问题,但我认为在我的情况下缩进是正确的。
I am kind of new to docker and docker compose. I am using 20.10.12 version of docker and 2.9.0 of portainer. My aim is to do the docker compose for elasticSearch to deploy it in portainer but I get a problem that the memory given is not enough. After looking through other questions I found that I could execute the following bash command to assign a bigger limit to the VM memory
sysctl -w vm.max_map_count=262144
So my .yml is like this:
version: "3.8"
services:
command: >
bash -c ' sysctl -w vm.max_map_count=262144'
master1:
image: docker.elastic.co/elasticsearch/elasticsearch:8.0.0
environment:
node.name: "master1"
ulimits:
memlock:
soft: -1
hard: -1
deploy:
endpoint_mode: dnsrr
mode: "replicated"
replicas: 1
resources:
limits:
memory: 4G
The problem is that when I try to deploy this compose, it says "services.command must be a mapping".
I think that problem is raised when then indentation is not correct but I think in my case is indented correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
vm.max_map_count
必须在主机上设置,而不是在 docker 容器中设置。按照 这个官方文档。
vm.max_map_count
must be set on the host, and not in the docker container.Set it as described in this official doc.