这是我的 docker compose yaml 文件
version: "3.7"
services:
dynamo:
image: bazel/production/local/docker/dynamodb:dynamodb
env_file: dynamodb/${ENV}.env
ports:
- 7070:7070
volumes:
- ${REPO}/production/local/docker/dynamodb/start_dynamo.sh:/home/dynamodblocal/start.sh
- dynamo-data:/home/dynamodblocal
entrypoint: ""
command: /home/dynamodblocal/start.sh
redis50_cluster:
image: bazel/production/local/docker/redis50:redis50
ports:
- 6380:6380
- 6381:6381
- 6382:6382
volumes:
- ${REPO}/production/local/docker/redis50/entrypoint.sh:/usr/local/bin/entrypoint.sh
- ${REPO}/production/local/docker/redis50/redis-cluster-node0.conf:/etc/redis/redis-cluster-node0.conf
- ${REPO}/production/local/docker/redis50/redis-cluster-node1.conf:/etc/redis/redis-cluster-node1.conf
- ${REPO}/production/local/docker/redis50/redis-cluster-node2.conf:/etc/redis/redis-cluster-node2.conf
- ${REPO}/production/local/docker/redis50/init_redis.sh:/usr/local/bin/init_redis.sh
- ${REPO}/production/local/docker/redis50/check_redis.sh:/usr/local/bin/check_redis.sh
- redis50-data:/data
healthcheck:
test: ["CMD", "check_redis.sh"]
interval: 60s
timeout: 5s
retries: 12
start_period: 10s
我只想启动 redis 服务,所以我尝试了这个命令
docker-compose -f docker-compose.yml up -d redis50_cluster
然而它失败了,因为
ERROR: Couldn't find env file: /Users/antkong/work/production/local/docker/dynamodb/local.env
我真的不关心 dynamodb 并且不想对其进行设置。
是否可以要求docker-compose
忽略 yml 文件其他部分的错误?
答案1
据我所知,yaml 文件需要“有效”,即使您只在其中启动一个容器。
在这种情况下,由于 env 文件不存在,docker-compose 将无法完成对文件的解析。
您可以通过以 # 符号开头的行来注释掉配置文件中有问题的行,然后启动您需要的内容。