Skip to content

DockerCommitImage does not tag newly created image correctly #1098

@looselytyped

Description

@looselytyped

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions