I am trying to setup my first docker compose complete application, and I have created a spring boot application that depends on mongodb. So, I have created a docker-compose.yml file at the root of my code, at the same level of Dockerfile. 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). So, I created the docker-compose.yml this way:
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:
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
Question: Does anyone knows how do I need to setup the docker-compose.yml file in order to not receive that error?
As @fernandezcuesta said,
You need to add version number for each docker-compose file.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.