buildscript { repositories { mavenCentral() } dependencies { classpath "com.avast.gradle:docker-compose-plugin:1.0.0" } }
apply plugin: 'docker-compose'
dockerCompose { filePath = "$projectDir/docker-compose.yml" environmentFiles = "$projectDir/.env" build = true removeOrphans = true }
3.检查docker-compose.yml文件是否正确编写,示例如下:
version: '3' services: myservice: container_name: myservice image: myimage ports: - "8080:8080" environment: - JAVA_OPTS=-Dspring.profiles.active=dev
4.最后可以尝试重新构建项目并启动docker-compose命令,查看是否成功。