我遇到此错误:
错误:服务'db'取决于未定义的服务'apache'。
为什么说apache未定义?我检查缩进。应该是正确的。
version: '3.5'
services:
apache:
build: ./Docker
image: apache:latest
ports:
- "80:80"
restart: always
networks:
default:
name: frontend-network
services:
db:
image: mariadb:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
depends_on:
- "apache"
adminer:
image: adminer
restart: always
ports:
- "8080:8080"
depends_on:
- "db"
networks:
default:
name: frontend-network
答案 0 :(得分:3)
否,未定义。您已经用另一个services
覆盖了。
您应该修复配置:
version: '3.5'
services:
apache:
build: ./Docker
image: apache:latest
ports:
- "80:80"
restart: always
db:
image: mariadb:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
depends_on:
- "apache"
adminer:
image: adminer
restart: always
ports:
- "8080:8080"
depends_on:
- "db"
networks:
default:
name: frontend-network
答案 1 :(得分:1)
@techraf是正确的。但是没有关键信息。切勿在撰写文件中写入2个服务。