【问题标题】:run linux containers on windows server 2019在 Windows Server 2019 上运行 linux 容器
【发布时间】:2021-08-24 08:31:15
【问题描述】:

我正在尝试在 Windows Server 2019 上运行 Redis 和 ElasticSearch 容器。但我遇到了错误。

这是我的 docker compose :

version: '3.7'

services:

  redis:
    image: redis:alpine
    command: redis-server --appendonly yes
    command: redis-server --requirepass 1234Abcd?!
    ports:
     - "6339:6379"
    volumes:
      - /volumes/redis/data:/data
    networks:
     - marketland 

  elasticsearch:
   image: elasticsearch:7.6.2
   volumes:
     - /volumes/elastic/data:/usr/share/elasticsearch/data
   volumes:
      - "esdata:/usr/share/elasticsearch/data"
   hostname: elasticsearch
   ports:
     - "9200:9200"
   environment:
     - discovery.type=single-node
     - bootstrap.memory_lock=true
   ulimits:
      memlock:
        soft: -1
        hard: -1
   networks:
     - marketland
     
  kibana:
   image: kibana:7.6.2
   ports:
     - "5601:5601"
   depends_on:
      - elasticsearch
   environment:
     - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
     - SERVER_NAME=kibana
   networks:
     - marketland
networks:
  marketland:
    external: true
volumes:
  esdata:

在执行 docker-compose -f docker-compose-pre up 后,我得到了这个错误:

Creating services_redis_1 ...
Creating services_elasticsearch_1 ... error
Creating services_redis_1         ... error
ERROR: for services_elasticsearch_1  Cannot create container for service elasticsearch: invalid option: Windows does not support Ulimits

ERROR: for services_redis_1  Cannot create container for service redis: failed to start service utility VM (createreadwrite): hcsshim::CreateComputeSystem 6821998c02d7861bd5fd6ca679dedcf30f9de574485632daed57d8fc872ae323_svm: The virtual machine could not be started because a required feature is not installed.
(extra info: {"SystemType":"container","Name":"6821998c02d7861bd5fd6ca679dedcf30f9de574485632daed57d8fc872ae323_svm","Layers":null,"HvPartition":true,"HvRuntime":{"ImagePath":"C:\\Program Files\\Linux Containers","LinuxInitrdFile":"initrd.img","LinuxKernelFile":"kernel"},"ContainerType":"linux","TerminateOnLastHandleClosed":true})

ERROR: for elasticsearch  Cannot create container for service elasticsearch: invalid option: Windows does not support Ulimits

ERROR: for redis  Cannot create container for service redis: failed to start service utility VM (createreadwrite): hcsshim::CreateComputeSystem 6821998c02d7861bd5fd6ca679dedcf30f9de574485632daed57d8fc872ae323_svm: The virtual machine could not be started because a required feature is not installed.
(extra info: {"SystemType":"container","Name":"6821998c02d7861bd5fd6ca679dedcf30f9de574485632daed57d8fc872ae323_svm","Layers":null,"HvPartition":true,"HvRuntime":{"ImagePath":"C:\\Program Files\\Linux Containers","LinuxInitrdFile":"initrd.img","LinuxKernelFile":"kernel"},"ContainerType":"linux","TerminateOnLastHandleClosed":true})
ERROR: Encountered errors while bringing up the project.

有没有办法在 Windows Server 2019 上运行这些容器?

** Hyper-v 已启用。

【问题讨论】:

  • 我在 Windows Server 2019 上的 Redis 容器也有同样的问题,你有什么消息吗?你找到解决办法了吗?

标签: docker elasticsearch redis


【解决方案1】:

您不能在 Windows 中设置 ulimit。删除以下行:

ulimits:
      memlock:
        soft: -1
        hard: -1

它只会解决您的弹性搜索问题。 我建议尝试在 linux 上使用 docker。

【讨论】:

    【解决方案2】:

    根据 hamid bayat 删除 ulimits

    redis 和 ElasticSearch 容器的容器到主机卷绑定在 Windows 上看起来也不正确。请参阅this SO,了解如何在 Windows 中定义卷。例如

    代替:

    volumes:
       /volumes/elastic/data:/usr/share/elasticsearch/data
    

    应该是这样的:

    volumes:
       - "C:/volumes/elastic/data:/usr/share/elasticsearch/data"
    

    注意:您在 ElasticSearch 容器中也有重复的 volumes - 您可以将两者放在一个下面,例如

    代替:

    volumes:
       - /volumes/elastic/data:/usr/share/elasticsearch/data
    volumes:
       - "esdata:/usr/share/elasticsearch/data"
    

    应该是:

    volumes:
       - /volumes/elastic/data:/usr/share/elasticsearch/data
       - "esdata:/usr/share/elasticsearch/data"
    

    【讨论】:

      【解决方案3】:

      我正在使用 windows10/Home 和 Linux Container,下面的 docker-complse.yml 对我来说很好,试试吧

      version: '3.1'
      
      services:
        redis:
          image: redis:alpine
          container_name: redis
          restart: always
          ports: 
            - 6379:6379
          volumes:
            - ./redis-data:/usr/share/Redis/data
      
        elastic_search:
          container_name: ElasticSearch
          image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
          ports:
            - 9200:9200
          volumes:
            - ./es-data/:/usr/share/elasticsearch/data
          environment: 
          - discovery.type=single-node
            
            
      

      【讨论】:

        猜你喜欢
        • 2020-02-05
        • 2020-02-06
        • 2021-07-18
        • 2022-08-10
        • 2020-04-20
        • 1970-01-01
        • 2017-02-01
        • 2021-08-07
        • 2021-02-28
        相关资源
        最近更新 更多