[英]docker-compose in windows: Unsupported config option for services: 'web'
I am trying to setup my first docker compose complete application, and I have created a spring boot application that depends on mongodb. 我正在尝试设置我的第一个docker compose完整应用程序,并且我创建了一个依赖于mongodb的spring boot应用程序。 So, I have created a docker-compose.yml file at the root of my code, at the same level of Dockerfile. 因此,我在代码的根目录(与Dockerfile处于同一级别)创建了一个docker-compose.yml文件。 When I create the image using gradlew build buildDocker
everuthing goes fine, and the image is created and I can run it (but it fails because it cannot open mongodb connection). 当我使用gradlew build buildDocker
创建映像时, gradlew build buildDocker
everuthing可以正常运行,并且映像已创建并且可以运行(但是由于无法打开mongodb连接而失败)。 So, I created the docker-compose.yml this way: 因此,我以这种方式创建了docker-compose.yml:
services:
web:
build: .
ports:
- "8082:8082"
links:
- mongo
mongo:
environment:
spring.data.mongodb.host: localhost
spring.data.mongodb.port: 27017
spring.data.mongodb.database: Transactions
spring.data.mongodb.username: someUsername
spring.data.mongodb.password: somePassword
image: "mongo:3.4"
However, when I execute docker-compose up
command, I get this error: 但是,当我执行docker-compose up
命令时,出现以下错误:
Unsupported config option for services: 'web'
I am using Windows 10 as OS, and the version of docker compose is docker-compose version 1.14.0, build c7bdf9e3
我正在使用Windows 10作为OS,并且docker-compose version 1.14.0, build c7bdf9e3
是docker-compose version 1.14.0, build c7bdf9e3
Question: Does anyone knows how do I need to setup the docker-compose.yml file in order to not receive that error? 问题:有谁知道我该如何设置docker-compose.yml文件才能不接收该错误?
As @fernandezcuesta said, 正如@fernandezcuesta所说,
You need to add version number for each docker-compose file. 您需要为每个docker-compose文件添加版本号。
Example : 范例:
version: '3.0'
services:
web:
build: .
ports:
- "8082:8082"
links:
- mongo
mongo:
environment:
spring.data.mongodb.host: localhost
spring.data.mongodb.port: 27017
spring.data.mongodb.database: Transactions
spring.data.mongodb.username: someUsername
spring.data.mongodb.password: somePassword
image: "mongo:3.4"
See documentation for more details. 有关更多详细信息,请参见文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.