webapp:
build: ./webapp
ports:
- "5000:5000"
volumes:
- .:/code
services:
sqlite3:
image: nouchka/sqlite3:latest
stdin_open: true
tty: true
volumes:
- ./db/:/Users/vijayraghunath/Desktop/assignment/webapp
上面是我的docker-compose.yml文件。当我尝试通过命令启动Python Flask Web应用程序时,
docker-compose up --build
它给出错误,如标题中所示。我正在使用sqlite数据库。
答案 0 :(得分:1)
在不包括版本行的情况下,您已经合并了版本1(不建议使用)语法,并将版本2语法合并到了services
顶层服务之下。您需要选择一种语法,而另一种则不能同时解析。
这是版本2的语法:
version: '2'
services:
sqlite3:
image: nouchka/sqlite3:latest
stdin_open: true
tty: true
volumes:
- ./db/:/Users/vijayraghunath/Desktop/assignment/webapp
webapp:
build: ./webapp
ports:
- "5000:5000"
volumes:
- .:/code
请注意,由于yaml对空格敏感,因此请注意文件中的空格。