gradle-docker-plugin
gradle-docker-plugin copied to clipboard
`DockerCommitImage` does not tag newly created image correctly
Expected Behavior
When attempting to commit a container using DockerCommitImage, a new image does get created, but does not get the correct tag.
DockerCommitImage seems to ignore the image attribute
Current Behavior
DockerCommitImage does indeed create a new image (you can see the image ID listed in docker image ls) but it does not have the correct repository and tag
Context
We are working on snapshotting a containerized DB for testing purposes. The container starts with some seed data, sees some modifications that we need to snapshot in a new image.
Steps to Reproduce (for bugs)
Please see this repository https://github.com/looselytyped/gradle-docker-plugin-issue that provides a sample Gradle file to demonstrate the issue.
The README.md also lists the steps to reproduce the issue.
Your Environment
- Operating System: macOS Big Sur Version 11.7
- Java version: openjdk version "11.0.2" 2019-01-15
- Gradle wrapper version: Gradle 7.2
- gradle-docker-plugin version: com.bmuschko:gradle-docker-plugin:6.7.0
- Docker version
❯ docker version
Client:
Cloud integration: v1.0.28
Version: 20.10.17
API version: 1.41
Go version: go1.17.11
Git commit: 100c701
Built: Mon Jun 6 23:04:45 2022
OS/Arch: darwin/amd64
Context: default
Experimental: true
Server: Docker Desktop 4.11.1 (84025)
Engine:
Version: 20.10.17
API version: 1.41 (minimum version 1.12)
Go version: go1.17.11
Git commit: a89b842
Built: Mon Jun 6 23:01:23 2022
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: 1.6.6
GitCommit: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc:
Version: 1.1.2
GitCommit: v1.1.2-0-ga916309
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Final notes
Changing my commit task to the following does the right thing:
task commit(type:Exec) {
dependsOn start
commandLine 'sh', '-c', "docker commit $contName $repo:$version-SNAPSHOT"
}
❯ docker image ls test/my-app
REPOSITORY TAG IMAGE ID CREATED SIZE
test/my-app 1.0.0-SNAPSHOT 1738aea5b379 10 minutes ago 5.86MB
test/my-app 1.0.0 79e6dcbca7e6 About an hour ago 5.86MB
Thank you 🙏🏽 for all your hard work on this plugin. Please let me know if I can provide any more details or context.
Any way you can try this with the latest version of the plugin? Your plugin version is quite old. If that doesn't do it then it might be an issue with Docker Java. I had a look at the task implementation and it looks correct to me.
Never mind. I think I see the issue. There's another method which we don't call: withRepository(String). We'd need to expose methods for setting the repository and the tag. Redoing the exposed methods would be a breaking change.
@bmuschko
Any way you can try this with the latest version of the plugin? Your plugin version is quite old
I am sorry—I apologize. I was following https://bmuschko.github.io/gradle-docker-plugin/#applying_the_plugin_using_the_plugin_dsl but you are right—I am quite behind. I see id "com.bmuschko.docker-remote-api" version "8.1.0" on https://plugins.gradle.org/plugin/com.bmuschko.docker-remote-api
Never mind. I think I see the issue.
Awesome. Please note that I upgraded the version in my repository to 8.1.0 so if you need to experiment you have a playground. Perhaps you'll have concluded—the issue persists, but at least we know for sure.
Please let me know if there is anything else I can provide.
And again, thank you for all the hard work. It's very much appreciated.
Thanks. I did find the issue and created a PR. I am planning to batch up some other changes for the release as we'd need to bump up to the next major version.
Thank you @bmuschko 🙏🏽
Much appreciated.