gpt4 book ai didi

docker - Portainer Docker Swarm 导入 secret 进行组合

转载 作者:行者123 更新时间:2023-12-03 08:22:37 26 4
gpt4 key购买 nike

在 Portainer swarm 中添加 Secrets 并尝试将其作为变量导入,任何人都可以举例说明如何导入它来撰写

version: '3.1'

services:
mongodb-sharded:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded
- MONGODB_SHARDING_MODE=mongos
- MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_REPLICA_SET_KEY=${MONGODB_KEY}
- MONGODB_ROOT_PASSWORD=${MONGODB_PASSWORD}
ports:
- "27017:27017"

最佳答案

使用 portariner Docker Swarm Secret 运行 mongodb 分片


version: '3.7'

secrets:
mongo-root-password:
external: true
mongo-key:
external: true


services:
mongodb-sharded:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded
- MONGODB_SHARDING_MODE=mongos
- MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
ports:
- "27017:27017"
secrets:
- mongo-key
- mongo-root-password

mongodb-sharded-2:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded-2
- MONGODB_SHARDING_MODE=mongos
- MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
secrets:
- mongo-key
- mongo-root-password

mongodb-shard0-primary:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-primary
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_REPLICA_SET_NAME=shard0
volumes:
- 'shard0_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password

mongodb-shard0-secondary:
image: docker.io/bitnami/mongodb-sharded:4.4
depends_on:
- mongodb-shard0-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-shard0-primary
- MONGODB_PRIMARY_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_REPLICA_SET_NAME=shard0
volumes:
- 'shard0_sec_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password

mongodb-shard1-primary:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-primary
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_REPLICA_SET_NAME=shard1
volumes:
- 'shard1_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password

mongodb-shard1-secondary:
image: docker.io/bitnami/mongodb-sharded:4.4
depends_on:
- mongodb-shard1-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-shard1-primary
- MONGODB_PRIMARY_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_REPLICA_SET_NAME=shard1
volumes:
- 'shard1_sec_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password

mongodb-shard2-primary:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard2-primary
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_REPLICA_SET_NAME=shard2
volumes:
- 'shard2_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password

mongodb-shard2-secondary:
image: docker.io/bitnami/mongodb-sharded:4.4
depends_on:
- mongodb-shard2-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard2-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-shard2-primary
- MONGODB_PRIMARY_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_REPLICA_SET_NAME=shard2
volumes:
- 'shard2_sec_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password

mongodb-cfg-primary:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg-primary
- MONGODB_SHARDING_MODE=configsvr
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_REPLICA_SET_NAME=cfgreplicaset
volumes:
- 'cfg_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password

mongodb-cfg-secondary:
image: docker.io/bitnami/mongodb-sharded:4.4
depends_on:
- mongodb-cfg-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_PRIMARY_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_SHARDING_MODE=configsvr
volumes:
- 'cfg_sec_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password

volumes:
shard0_data:
driver: local
shard0_sec_data:
driver: local
shard1_data:
driver: local
shard1_sec_data:
driver: local
shard2_data:
driver: local
shard2_sec_data:
driver: local
cfg_data:
driver: local
cfg_sec_data:
driver: local

关于docker - Portainer Docker Swarm 导入 secret 进行组合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67408934/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com