| Error Error initializing classpath: Could not set unknown property 'env' for task ':createPostgresContainer' of type com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer. (Use --stacktrace to see the full trace)
https://bmuschko.github.io/gradle-docker-plugin/
我正在使用此Gradle Docker插件来设置Postgres Docker容器,以通过以下示例在Mac上测试一些数据库相关的内容。 http://guides.grails.org/grails-docker-external-services/guide/index.html
但由于无法像这样设置env字符串,因此似乎无法解决问题:
task createPostgresContainer(type: DockerCreateContainer, dependsOn: pullPostgresImage) {
group = "docker"
ext {
pgContainerName = "demo-db"
dbName = "demo-db"
dbPort = 5432
dbPassword = "kevintan"
}
description = 'Creates PostgreSQL container'
containerName = pgContainerName
imageId = pullPostgresImage.imageName+":"+pullPostgresImage.tag
portBindings = ["${dbPort}:5432"]
env = [
"POSTGRES_PASSWORD=${dbPassword}",
"POSTGRES_DB=${dbName}",
] as String[]
onError { e ->
if (e.class.simpleName in ['BadRequestException', 'ConflictException']) {
logger.warn 'Container already exists'
} else {
throw e
}
}
}
有什么办法设置环境?还是我错过了什么?
答案 0 :(得分:0)
没关系。我忘了阅读变更日志。
删除了DockerCreateContainer.env,由DockerCreateContainer.envVars代替