Docker compose gradle 插件以“dockerspect”退出需要至少 1 个参数
我有以下 docker-compose 文件:
version: '3.1'
services:
localstack:
image: localstack/localstack:0.9.6
ports:
- "4576:4576"
environment:
- SERVICES=sqs:4576
- HOSTNAME_EXTERNAL=localhost
- DEBUG=0
- START_WEB=0
primarydb:
image: mysql:5.6
environment:
MYSQL_USER: test-user
MYSQL_PASSWORD: test-password
MYSQL_DATABASE: testdb
MYSQL_ROOT_PASSWORD: test-password
ports:
- "3318:3306"
我有以下 gradle 配置:
apply plugin: 'docker-compose'
dockerCompose.isRequiredBy(project.tasks.getByName('test'))
dockerCompose {
useComposeFiles = ['docker-compose.yml']
startedServices = ['localstack', 'primarydb']
projectName = "${rootProject.name}"
}
project.tasks.getByName('test').doFirst {
systemProperty 'localstack.sqs.endpoint', "http://localhost:4576"
systemProperty 'mysql.url', "jdbc:mysql://localhost:3318"
}
我正在使用最新的 docker-compose 插件: com.avast.gradle:gradle-docker-compose-plugin:0.15.1
由于某种原因,该构建可以在我朋友的 Linux 机器上运行,但不能在 MacOS 11.4 上运行。 当我运行 ./gradlew composeUp
任务时,它失败并显示以下错误消息:
./gradlew composeUp
> Configure project :
2.5.25-SNAPSHOT
> Task :composeUp
Container primarydb-1 Running
Container localstack-1 Recreate
Container localstack-1 Recreated
Container localstack-1 Starting
Container localstack-1 Started
"docker inspect" requires at least 1 argument.
See 'docker inspect --help'.
Usage: docker inspect [OPTIONS] NAME|ID [NAME|ID...]
Return low-level information on Docker objects
> Task :composeUp FAILED
...
知道为什么这个插件不能在 Mac 上运行,但可以在我朋友的机器上运行吗?
I have the following docker-compose file:
version: '3.1'
services:
localstack:
image: localstack/localstack:0.9.6
ports:
- "4576:4576"
environment:
- SERVICES=sqs:4576
- HOSTNAME_EXTERNAL=localhost
- DEBUG=0
- START_WEB=0
primarydb:
image: mysql:5.6
environment:
MYSQL_USER: test-user
MYSQL_PASSWORD: test-password
MYSQL_DATABASE: testdb
MYSQL_ROOT_PASSWORD: test-password
ports:
- "3318:3306"
And I have the following gradle configuration:
apply plugin: 'docker-compose'
dockerCompose.isRequiredBy(project.tasks.getByName('test'))
dockerCompose {
useComposeFiles = ['docker-compose.yml']
startedServices = ['localstack', 'primarydb']
projectName = "${rootProject.name}"
}
project.tasks.getByName('test').doFirst {
systemProperty 'localstack.sqs.endpoint', "http://localhost:4576"
systemProperty 'mysql.url', "jdbc:mysql://localhost:3318"
}
And I am using the latest docker-compose plugin: com.avast.gradle:gradle-docker-compose-plugin:0.15.1
For some reason, the build works on my friend's Linux machine, but it doesn't work on MacOS 11.4.
When I run ./gradlew composeUp
task it just fails with the following error message:
./gradlew composeUp
> Configure project :
2.5.25-SNAPSHOT
> Task :composeUp
Container primarydb-1 Running
Container localstack-1 Recreate
Container localstack-1 Recreated
Container localstack-1 Starting
Container localstack-1 Started
"docker inspect" requires at least 1 argument.
See 'docker inspect --help'.
Usage: docker inspect [OPTIONS] NAME|ID [NAME|ID...]
Return low-level information on Docker objects
> Task :composeUp FAILED
...
Any idea why this plugin doesn't work on a mac but works on my friend's machine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的错误。运行
./gradle composeUp --stacktrace
给出了com.avast.gradle:gradle-docker-compose-plugin:0.15.1
正在做什么的线索。本质上是:docker-compose -p <项目名称>; config --services
和最后docker-compose -p <项目名称>; ps --services
最后一步是我失败的一步(也是目前你失败的一步。)手动重复 compose-commands 并查看 Docker 桌面 UI,我可以看到,那个 docker-compose 确实通过删除其中的任何点来改变我的项目名称。重新指定后
,确保 docker-compose 不会更改项目名称,确实为我解决了问题。
您的错误原因可能仍然是不同的。尝试使用
--stacktrace
、--info
甚至--debug
运行./gradlew composeUp
来获取更好地了解出了什么问题。I faced the same error. Running
./gradle composeUp --stacktrace
gave a clue whatcom.avast.gradle:gradle-docker-compose-plugin:0.15.1
is doing. In essence to does:docker-compose -p <project name> up
docker-compose -p <project name> config --services
and finallydocker-compose -p <project name> ps --services
The third a last step is the one which was failing on me (and is the one currently failing on you.) Repeating the compose-commands manually and having a look into the Docker Desktop UI I could see, that docker-compose did alter my project-name by removing any dots from it. After respecifying
thus ensuring that docker-compose wont alter the project name, did solve the issue for me.
Your error cause migth still be a different one. Try running
./gradlew composeUp
with--stacktrace
,--info
or even--debug
to get a better understanding of what is going wrong.