RemoteImage

class RemoteImage : KotlinCustomResource

Pulls a Docker image to a given Docker host from a Docker Registry. This resource will not pull new layers of the image automatically unless used in conjunction with docker.RegistryImage data source to update the pull_triggers field.

Example Usage

Basic

Finds and downloads the latest ubuntu:precise image but does not check for further updates of the image

import * as pulumi from "@pulumi/pulumi";
import * as docker from "@pulumi/docker";
const ubuntu = new docker.RemoteImage("ubuntu", {name: "ubuntu:precise"});
import pulumi
import pulumi_docker as docker
ubuntu = docker.RemoteImage("ubuntu", name="ubuntu:precise")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Docker = Pulumi.Docker;
return await Deployment.RunAsync(() =>
{
var ubuntu = new Docker.RemoteImage("ubuntu", new()
{
Name = "ubuntu:precise",
});
});
package main
import (
"github.com/pulumi/pulumi-docker/sdk/v4/go/docker"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := docker.NewRemoteImage(ctx, "ubuntu", &docker.RemoteImageArgs{
Name: pulumi.String("ubuntu:precise"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.docker.RemoteImage;
import com.pulumi.docker.RemoteImageArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var ubuntu = new RemoteImage("ubuntu", RemoteImageArgs.builder()
.name("ubuntu:precise")
.build());
}
}
resources:
ubuntu:
type: docker:RemoteImage
properties:
name: ubuntu:precise

Dynamic updates

To be able to update an image dynamically when the sha256 sum changes, you need to use it in combination with docker.RegistryImage as follows:

import * as pulumi from "@pulumi/pulumi";
import * as docker from "@pulumi/docker";
const ubuntu = docker.getRegistryImage({
name: "ubuntu:precise",
});
const ubuntuRemoteImage = new docker.RemoteImage("ubuntu", {
name: ubuntu.then(ubuntu => ubuntu.name),
pullTriggers: [ubuntu.then(ubuntu => ubuntu.sha256Digest)],
});
import pulumi
import pulumi_docker as docker
ubuntu = docker.get_registry_image(name="ubuntu:precise")
ubuntu_remote_image = docker.RemoteImage("ubuntu",
name=ubuntu.name,
pull_triggers=[ubuntu.sha256_digest])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Docker = Pulumi.Docker;
return await Deployment.RunAsync(() =>
{
var ubuntu = Docker.GetRegistryImage.Invoke(new()
{
Name = "ubuntu:precise",
});
var ubuntuRemoteImage = new Docker.RemoteImage("ubuntu", new()
{
Name = ubuntu.Apply(getRegistryImageResult => getRegistryImageResult.Name),
PullTriggers = new[]
{
ubuntu.Apply(getRegistryImageResult => getRegistryImageResult.Sha256Digest),
},
});
});
package main
import (
"github.com/pulumi/pulumi-docker/sdk/v4/go/docker"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
ubuntu, err := docker.LookupRegistryImage(ctx, &docker.LookupRegistryImageArgs{
Name: "ubuntu:precise",
}, nil)
if err != nil {
return err
}
_, err = docker.NewRemoteImage(ctx, "ubuntu", &docker.RemoteImageArgs{
Name: pulumi.String(ubuntu.Name),
PullTriggers: pulumi.StringArray{
pulumi.String(ubuntu.Sha256Digest),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.docker.DockerFunctions;
import com.pulumi.docker.inputs.GetRegistryImageArgs;
import com.pulumi.docker.RemoteImage;
import com.pulumi.docker.RemoteImageArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var ubuntu = DockerFunctions.getRegistryImage(GetRegistryImageArgs.builder()
.name("ubuntu:precise")
.build());
var ubuntuRemoteImage = new RemoteImage("ubuntuRemoteImage", RemoteImageArgs.builder()
.name(ubuntu.applyValue(getRegistryImageResult -> getRegistryImageResult.name()))
.pullTriggers(ubuntu.applyValue(getRegistryImageResult -> getRegistryImageResult.sha256Digest()))
.build());
}
}
resources:
ubuntuRemoteImage:
type: docker:RemoteImage
name: ubuntu
properties:
name: ${ubuntu.name}
pullTriggers:
- ${ubuntu.sha256Digest}
variables:
ubuntu:
fn::invoke:
function: docker:getRegistryImage
arguments:
name: ubuntu:precise

Build

You can also use the resource to build an image. In this case the image "zoo" and "zoo:develop" are built.

import * as pulumi from "@pulumi/pulumi";
import * as docker from "@pulumi/docker";
const zoo = new docker.RemoteImage("zoo", {
name: "zoo",
build: {
context: ".",
tags: ["zoo:develop"],
buildArg: {
foo: "zoo",
},
label: {
author: "zoo",
},
},
});
import pulumi
import pulumi_docker as docker
zoo = docker.RemoteImage("zoo",
name="zoo",
build={
"context": ".",
"tags": ["zoo:develop"],
"build_arg": {
"foo": "zoo",
},
"label": {
"author": "zoo",
},
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Docker = Pulumi.Docker;
return await Deployment.RunAsync(() =>
{
var zoo = new Docker.RemoteImage("zoo", new()
{
Name = "zoo",
Build = new Docker.Inputs.RemoteImageBuildArgs
{
Context = ".",
Tags = new[]
{
"zoo:develop",
},
BuildArg =
{
{ "foo", "zoo" },
},
Label =
{
{ "author", "zoo" },
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-docker/sdk/v4/go/docker"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := docker.NewRemoteImage(ctx, "zoo", &docker.RemoteImageArgs{
Name: pulumi.String("zoo"),
Build: &docker.RemoteImageBuildArgs{
Context: pulumi.String("."),
Tags: pulumi.StringArray{
pulumi.String("zoo:develop"),
},
BuildArg: pulumi.StringMap{
"foo": pulumi.String("zoo"),
},
Label: pulumi.StringMap{
"author": pulumi.String("zoo"),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.docker.RemoteImage;
import com.pulumi.docker.RemoteImageArgs;
import com.pulumi.docker.inputs.RemoteImageBuildArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var zoo = new RemoteImage("zoo", RemoteImageArgs.builder()
.name("zoo")
.build(RemoteImageBuildArgs.builder()
.context(".")
.tags("zoo:develop")
.buildArg(Map.of("foo", "zoo"))
.label(Map.of("author", "zoo"))
.build())
.build());
}
}
resources:
zoo:
type: docker:RemoteImage
properties:
name: zoo
build:
context: .
tags:
- zoo:develop
buildArg:
foo: zoo
label:
author: zoo

You can use the triggers argument to specify when the image should be rebuild. This is for example helpful when you want to rebuild the docker image whenever the source code changes.

Properties

Link copied to clipboard
val build: Output<RemoteImageBuild>?

Configuration to build an image. Please see docker build command reference too.

Link copied to clipboard
val forceRemove: Output<Boolean>?

If true, then the image is removed forcibly when the resource is destroyed.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val imageId: Output<String>

The ID of the image (as seen when executing docker inspect on the image). Can be used to reference the image via its ID in other resources.

Link copied to clipboard
val keepLocally: Output<Boolean>?

If true, then the Docker image won't be deleted on destroy operation. If this is false, it will delete the image from the docker local storage on destroy operation.

Link copied to clipboard
val name: Output<String>

The name of the Docker image, including any tags or SHA256 repo digests.

Link copied to clipboard
val platform: Output<String>?

The platform to use when pulling the image. Defaults to the platform of the current machine.

Link copied to clipboard
val pullTriggers: Output<List<String>>?

List of values which cause an image pull when changed. This is used to store the image digest from the registry when using the dockerregistryimage.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val repoDigest: Output<String>

The image sha256 digest in the form of repo[:tag]@sha256:<hash>.

Link copied to clipboard
val triggers: Output<Map<String, String>>?

A map of arbitrary strings that, when changed, will force the docker.RemoteImage resource to be replaced. This can be used to rebuild an image when contents of source code folders change

Link copied to clipboard
val urn: Output<String>