question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support creation of Docker tags

See original GitHub issue

Description of the issue: The Jib Gradle/Maven plugins should support the creation of Docker tags without building a new image. This is important for promotion workflows where an image gains new tags while being promoted through the stages.

Expected behavior:

Something like the command below creates a tag in the repository repo:

gradle jibTag --source "repo/img:$GIT_COMMIT" --target "repo/img:$GIT_TAG"

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
coollogcommented, Feb 27, 2019

Hi @gluehbirnenkopf , this seems like a use case that is outside the scope of Jib, since Jib is intended to be just a container builder for Java.

For a standalone tool to copy remote images, I would recommend crane.

If you’d like to copy an image as part of your Gradle build, you could use Jib Core:

// Imports Jib Core as a library to use in this build script.
buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.google.cloud.tools:jib-core:0.1.1'
  }
}

import com.google.cloud.tools.jib.api.Jib
import com.google.cloud.tools.jib.api.Containerizer
import com.google.cloud.tools.jib.api.RegistryImage
import com.google.cloud.tools.jib.frontend.CredentialRetrieverFactory
import com.google.cloud.tools.jib.image.ImageReference

// 'jibcopy' copies a container image from `sourceImage` to `targetImage`.
task('jibcopy') {
  doLast { 
    def sourceImage = '<source image reference>'
    def targetImage = '<target image reference>'
    Jib
        // Starts with the existing image.
        .from(sourceImage)
        // Performs the containerization.
        .containerize(
            Containerizer.to(
                // Tells Jib to containerize to targetImage's registry. 
                RegistryImage
                    .named(targetImage)
                    // Tells Jib to get registry credentials from a Docker config.
                    .addCredentialRetriever(
                        CredentialRetrieverFactory
                            .forImage(ImageReference.parse(targetImage))
                            .dockerConfig())))
  }
}
1reaction
coollogcommented, Jul 18, 2018

Hi @az82 , in Jib, you can actually push the same image with a different tag (just change the to.image field, or create profiles to use multiple tags). Even though it might seem like Jib is building a new image - it skips all the actual building and just creates a new manifest for the new tag. This is a benefit we get from the reproducibility aspect of Jib, where the image layers that were pushed in the first tag would get reused by the new tags.

Read more comments on GitHub >

github_iconTop Results From Across the Web

docker tag
You can group your images together using names and tags, and then upload them to Share images on Docker Hub. For example uses...
Read more >
A quick introduction to Docker tags - freeCodeCamp
In simple words, Docker tags convey useful information about a specific image version/variant. They are aliases to the ID of your image which ......
Read more >
A Guide to Tag in Docker - Baeldung
In this tutorial, we'll learn the concept of tags in Docker. Docker provides the support for storing the images on the Docker Hub...
Read more >
The Fundamentals of Docker Image Tags | Atomist Blog
Docker tags make it easy to benefit from the hard work of others by running their images directly or by creating new derived...
Read more >
Understanding Docker image tags and publishing ... - ITNEXT
Like a package must have a unique name and version, since Docker images can be shared publically, REPOSITORY and the TAG column does...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found