• docker-compose 搭建redis集群 docker.errors.InvalidArgument: “host” network_mode异常


    导致原因是开启host网络模式,不能设置ports 。所以注释掉ports就可以了

    1. version: "3"
    2. services:
    3. redis-master1:
    4. image: redis # 基础镜像
    5. container_name: node1 # 容器名称
    6. working_dir: /config # 切换工作目录
    7. environment: # 环境变量
    8. - PORT=6391 # 会使用config/nodes-${PORT}.conf这个配置文件
    9. #ports: # 映射端口,对外提供服务
    10. #- 6391:6391 # redis的服务端口
    11. #- 16391:16391 # redis集群监控端口
    12. stdin_open: true # 标准输入打开
    13. tty: true # 后台运行不退出
    14. network_mode: host # 使用host模式
    15. privileged: true # 拥有容器内命令执行的权限
    16. volumes:
    17. - /mydata/redis-cluster/config:/config #配置文件目录映射到宿主机
    18. entrypoint: # 设置服务默认的启动程序
    19. - /bin/bash
    20. - redis.sh
    21. redis-master2:
    22. image: redis
    23. working_dir: /config
    24. container_name: node2
    25. environment:
    26. - PORT=6392
    27. #ports:
    28. #- 6392:6392
    29. #- 16392:16392
    30. stdin_open: true
    31. network_mode: host
    32. tty: true
    33. privileged: true
    34. volumes:
    35. - /mydata/redis-cluster/config:/config
    36. entrypoint:
    37. - /bin/bash
    38. - redis.sh
    39. redis-master3:
    40. image: redis
    41. container_name: node3
    42. working_dir: /config
    43. environment:
    44. - PORT=6393
    45. #ports:
    46. #- 6393:6393
    47. #- 16393:16393
    48. stdin_open: true
    49. network_mode: host
    50. tty: true
    51. privileged: true
    52. volumes:
    53. - /mydata/redis-cluster/config:/config
    54. entrypoint:
    55. - /bin/bash
    56. - redis.sh
    57. redis-slave1:
    58. image: redis
    59. container_name: node4
    60. working_dir: /config
    61. environment:
    62. - PORT=6394
    63. #ports:
    64. #- 6394:6394
    65. #- 16394:16394
    66. stdin_open: true
    67. network_mode: host
    68. tty: true
    69. privileged: true
    70. volumes:
    71. - /mydata/redis-cluster/config:/config
    72. entrypoint:
    73. - /bin/bash
    74. - redis.sh
    75. redis-slave2:
    76. image: redis
    77. working_dir: /config
    78. container_name: node5
    79. environment:
    80. - PORT=6395
    81. #ports:
    82. #- 6395:6395
    83. #- 16395:16395
    84. stdin_open: true
    85. network_mode: host
    86. tty: true
    87. privileged: true
    88. volumes:
    89. - /mydata/redis-cluster/config:/config
    90. entrypoint:
    91. - /bin/bash
    92. - redis.sh
    93. redis-slave3:
    94. image: redis
    95. container_name: node6
    96. working_dir: /config
    97. environment:
    98. - PORT=6396
    99. #ports:
    100. #- 6396:6396
    101. #- 16396:16396
    102. stdin_open: true
    103. network_mode: host
    104. tty: true
    105. privileged: true
    106. volumes:
    107. - /mydata/redis-cluster/config:/config
    108. entrypoint:
    109. - /bin/bash
    110. - redis.sh

    修改完以后顺利搭建成功

  • 相关阅读:
    python项目开发常用的目录结构
    干货分享 | 关于同星硬件接口卡及TSMaster软件常见问题Q&A指南
    【代码随想录刷题】栈与队列总结
    (待完善)python学习参考手册
    测试开发日记:locust压测带你小试牛刀
    JAVA家政服务管理系统毕业设计 开题报告
    《DevOps实践指南》笔记:第7章
    【Rust 易学教程】学前准备:Cargo, 你好
    【Rust 笔记】15-字符串与文本(下)
    C++ AVL树
  • 原文地址:https://blog.csdn.net/Accpdaiyekun/article/details/126322453