gpt4 book ai didi

azure - `docker-compose up` 与 `docker compose up` 与环境变量

转载 作者:行者123 更新时间:2023-12-02 06:05:27 28 4
gpt4 key购买 nike

我正在尝试使用 Docker Compose 将三节点 Elasticsearch 集群部署到 Azure 容器实例。我正在松散地关注this example来自 Elasticsearch 文档和 this tutorial来自 ACI 文档。

当我尝试使用标准 docker-compose 部署到 ACI 时当我在大多数文档中看到命令时,我收到一条错误消息,指出不支持该命令:

> docker-compose -f .\docker-compose.yml -f .\docker-compose.production.yml up
ERROR: The platform targeted with the current context is not supported.
Make sure the context in use targets a Docker Engine.

当我尝试使用 docker compose 部署到 ACI 时(无连字符)来自 ACI 文档的命令,我收到错误,因为它没有从 .env 文件加载环境变量:

> docker compose -f .\docker-compose.yml -f .\docker-compose.production.yml up
1 error(s) decoding:

* error decoding 'Volumes[1]': invalid spec: certs:: empty section between colons

使用docker compose时有没有办法加载.env文件,或使用docker-compose与ACI?我不完全明白docker compose在哪里命令来自以及为什么它与 docker-compose 不同,好像不太标准docker我可以看到的命令或 CLI 扩展。

这些是相关文件:

docker-compose.yml

# Based on example from Elasticsearch documentation:
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker

version: '3.8'
services:

es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- ELASTIC_PASSWORD=$ELASTIC_PASSWORD
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.enabled=true
- xpack.security.http.ssl.enabled=true
- xpack.security.http.ssl.key=$CERTS_DIR/es01/es01.key
- xpack.security.http.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.http.ssl.certificate=$CERTS_DIR/es01/es01.crt
- xpack.security.transport.ssl.enabled=true
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.security.transport.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.transport.ssl.certificate=$CERTS_DIR/es01/es01.crt
- xpack.security.transport.ssl.key=$CERTS_DIR/es01/es01.key
volumes:
- data01:/usr/share/elasticsearch/data
- 'certs:$CERTS_DIR'
ports:
- 127.0.0.1:9200:9200
networks:
- elastic
healthcheck:
test: curl --cacert $CERTS_DIR/ca/ca.crt -s https://localhost:9200 >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
interval: 30s
timeout: 10s
retries: 5
ulimits:
memlock:
soft: -1
hard: -1

es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
container_name: es02
environment:
- node.name=es02
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.http.ssl.key=$CERTS_DIR/es02/es02.key
- xpack.security.http.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.http.ssl.certificate=$CERTS_DIR/es02/es02.crt
- xpack.security.transport.ssl.enabled=true
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.security.transport.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.transport.ssl.certificate=$CERTS_DIR/es02/es02.crt
- xpack.security.transport.ssl.key=$CERTS_DIR/es02/es02.key
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data02:/usr/share/elasticsearch/data
- 'certs:$CERTS_DIR'
networks:
- elastic

es03:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
container_name: es03
environment:
- node.name=es03
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es02
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.http.ssl.key=$CERTS_DIR/es03/es03.key
- xpack.security.http.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.http.ssl.certificate=$CERTS_DIR/es03/es03.crt
- xpack.security.transport.ssl.enabled=true
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.security.transport.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.transport.ssl.certificate=$CERTS_DIR/es03/es03.crt
- xpack.security.transport.ssl.key=$CERTS_DIR/es03/es03.key
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data03:/usr/share/elasticsearch/data
- 'certs:$CERTS_DIR'
networks:
- elastic

wait_until_ready:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
command: /usr/bin/true
depends_on: {"es01": {"condition": "service_healthy"}}

volumes:
data01:
data02:
data03:
certs:

networks:
elastic:
driver: bridge

docker-compose.生产.yml:

x-volume: &volume
driver: azure_file
driver_opts:
share_name: acishare
storage_account_name: <My Storage Account Name>

volumes:
data01:
<<: *volume
data02:
<<: *volume
data03:
<<: *volume
certs:
<<: *volume

.env

COMPOSE_PROJECT_NAME=es
CERTS_DIR=/usr/share/elasticsearch/config/certificates
ELASTIC_PASSWORD=<Default Password>

我也尝试过使用 env_file属性(property),但是docker compose好像忽略了。

最佳答案

基于this GitHub issue comment ,看来docker-compose是最初的Compose项目,它的源代码位于 docker/compose存储库。

docker compose是一个新项目,实现了Compose规范,支持ECS和ACI,但尚不支持本地部署。其源代码位于 docker/compose-cli存储库。

根据this issue , docker compose 尚不支持 .env 文件。

关于azure - `docker-compose up` 与 `docker compose up` 与环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64904390/

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