直接上正确的配置文件:

es:
  image: elasticsearch:7.14.0
  container_name: es
  environment:
    - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    - discovery.type=single-node
  ports:
    - 9200:9200
    - 9300:9300

以上是我能够正确启动的配置文件,之前尝试启动的时候报了两个错,分别给出解决方法:

1.max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

修改sysctl.conf文件,添加一行:vm.max_map_count=262144

vi /etc/sysctl.conf
# 添加一行
vm.max_map_count=262144

使配置文件立即生效

/sbin/sysctl -p

2.the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

这个错误是es启动配置确实导致的,environment中添加discovery.type=single-node即可,如前文中的配置文件。

enviroment:
  - discovery.type=single-node

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐