https://pulumi.com logo
#typescript
Title
# typescript
g

gentle-state-12755

03/15/2023, 9:31 PM
Hello, I am having an issue creating a secondary TAG on a Docker Image using the new
@pulumi/docker
v4.0.0: The example below shows how to create and push a Docker Image with tag
xyz
, but how can I tag the image with a secondary TAG
latest
?
Copy code
const demoImage = new docker.Image("demo-image", {
    build: {
        context: ".",
        dockerfile: "Dockerfile",
    },
    imageName: "host/image:xyz"
});
The desired result is to being able to publish both: •
host/image:latest
host/image:xyz
I tried using the
docker.Tag
resource, without success
Copy code
new docker.Tag("demo-tag", {
    sourceImage: "host/image:xyz",
    targetImage: "host/image:latest",
  }, {
    dependsOn: [
      demoImage,
    ],
  });
b

billowy-army-68599

03/15/2023, 10:29 PM
this works for me
Copy code
const demoImage = new docker.Image("demo-image", {
    build: {
        context: ".",
        dockerfile: "Dockerfile",
    },
    imageName: "test/image:bar",
    skipPush: true,
});

new docker.Tag("demo-tag", {
    sourceImage: demoImage.imageName as pulumi.Output<string>, // ensure the optional type is string
    targetImage: "test/image:foo",
  });
s

stocky-restaurant-98004

03/15/2023, 10:33 PM
@gentle-state-12755 Is this a multi-platform image? If so, that's why it might not work.
g

gentle-state-12755

03/15/2023, 10:51 PM
@billowy-army-68599 I see what is happening. you are right, locally the tag
foo
is created correctly But how to push
foo
remotely together with
bar
?
Copy code
const demoImage = new docker.Image("demo-image", {
    build: {
        context: ".",
        dockerfile: "Dockerfile",
    },
    imageName: "host/image:bar",
    registry: {...},
});

new docker.Tag("demo-tag", {
    sourceImage: demoImage.imageName as pulumi.Output<string>,
    targetImage: "test/image:foo",
  });
The
bar
tag is found in the remote repository
host
, but not the
foo
tag
b

billowy-army-68599

03/15/2023, 10:56 PM
We might need to make tag an array,‘could you file an issue
g

gentle-state-12755

03/15/2023, 10:58 PM
sure thing. just to make sure I get what you are talking about: you suggest a change to support something like ?
Copy code
const demoImage = new docker.Image("demo-image", {
    build: {
        context: ".",
        dockerfile: "Dockerfile",
    },
    imageName: "host/image",
    tags: [
      'foo',
      'bar'
    ],
    registry: {...},
});
b

billowy-army-68599

03/15/2023, 11:01 PM
Or an array for imageName
g

gentle-state-12755

03/15/2023, 11:02 PM
b

billowy-army-68599

03/16/2023, 5:15 PM
it occured to me last night @gentle-state-12755 the right way is probably this
Copy code
const demoImage = new docker.Image("demo-image", {
    build: {
        context: ".",
        dockerfile: "Dockerfile",
    },
    imageName: "test/image:bar",
    skipPush: true,
});

const demoImageTag = new docker.Image("demo-image-tag", {
        imageName: "test/image:foo",
        skipPush: true,
        build: {
            context: ".",
            dockerfile: "Dockerfile",
        }
})
Let the underlying docker caching do the work
g

gentle-state-12755

03/16/2023, 5:18 PM
yes, but I guess one should
dependOn
the other. If not, is docker going to try to build them in parallel ?
b

billowy-army-68599

03/16/2023, 5:19 PM
yeah that’d work
4 Views