Want to learn about running containers in Lambda? Join our free hands-on workshop. Register Now

Docker

The Docker provider for Pulumi can be used to provision any of the resources available in Docker.

See the full API documentation for complete details of the available Docker provider APIs.

Setup

The Docker provider supports several options for interacting with Docker. See the Docker setup page for details.

Example

const docker = require("@pulumi/docker")

const image = new docker.RemoteImage("ubuntu", {
  name: "ubuntu:precise"
});

const container = new docker.Container("ubuntu", {
  image: image.latest,
});
import * as docker from "@pulumi/docker";

const image = new docker.RemoteImage("ubuntu", {
  name: "ubuntu:precise"
});

const container = new docker.Container("ubuntu", {
  image: image.latest,
});
import pulumi_docker as docker

image = docker.RemoteImage("ubuntu",
  name='ubuntu:precise'
)

container = docker.Container("ubuntu",
  image=image.latest
)
import (
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
    do "github.com/pulumi/pulumi-docker/sdk/v2/go/docker"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        image, err := docker.NewRemoteImage(ctx, "ubuntu", &docker.RemoteImageArgs{
            Name: pulumi.String("ubuntu:precise"),
        })
        if err != nil {
            return err
        }

        container, err := docker.NewContainer(ctx, "ubuntu", &docker.ContainerArgs{
            Image: image.Latest(),
        })
        if err != nil {
            return err
        }

        return nil
    })
}
using System.Collections.Generic;
using System.Threading.Tasks;
using Pulumi;
using Pulumi.Docker;

class Program
{
    static Task Main() =>
        Deployment.Run(() => {
            var image = new Docker.RemoteImage("ubuntu", new Docker.RemoteImageArgs
            {
                Name = "ubuntu:precise",
            });

            var container = new Docker.Container("ubuntu", new Docker.ContainerArgs
            {
                Image = image.Latest,
            });
        });
}

Libraries

The following packages are available in packager managers:

The Docker provider is open source and available in the pulumi/pulumi-docker repo.