Container Args
Manages the lifecycle of a Docker container.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as docker from "@pulumi/docker";
// Find the latest Ubuntu precise image.
const ubuntuRemoteImage = new docker.RemoteImage("ubuntu", {name: "ubuntu:precise"});
// Start a container
const ubuntu = new docker.Container("ubuntu", {
name: "foo",
image: ubuntuRemoteImage.imageId,
});
import pulumi
import pulumi_docker as docker
# Find the latest Ubuntu precise image.
ubuntu_remote_image = docker.RemoteImage("ubuntu", name="ubuntu:precise")
# Start a container
ubuntu = docker.Container("ubuntu",
name="foo",
image=ubuntu_remote_image.image_id)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Docker = Pulumi.Docker;
return await Deployment.RunAsync(() =>
{
// Find the latest Ubuntu precise image.
var ubuntuRemoteImage = new Docker.RemoteImage("ubuntu", new()
{
Name = "ubuntu:precise",
});
// Start a container
var ubuntu = new Docker.Container("ubuntu", new()
{
Name = "foo",
Image = ubuntuRemoteImage.ImageId,
});
});
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 {
// Find the latest Ubuntu precise image.
ubuntuRemoteImage, err := docker.NewRemoteImage(ctx, "ubuntu", &docker.RemoteImageArgs{
Name: pulumi.String("ubuntu:precise"),
})
if err != nil {
return err
}
// Start a container
_, err = docker.NewContainer(ctx, "ubuntu", &docker.ContainerArgs{
Name: pulumi.String("foo"),
Image: ubuntuRemoteImage.ImageId,
})
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.Container;
import com.pulumi.docker.ContainerArgs;
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) {
// Find the latest Ubuntu precise image.
var ubuntuRemoteImage = new RemoteImage("ubuntuRemoteImage", RemoteImageArgs.builder()
.name("ubuntu:precise")
.build());
// Start a container
var ubuntu = new Container("ubuntu", ContainerArgs.builder()
.name("foo")
.image(ubuntuRemoteImage.imageId())
.build());
}
}
resources:
# Start a container
ubuntu:
type: docker:Container
properties:
name: foo
image: ${ubuntuRemoteImage.imageId}
# Find the latest Ubuntu precise image.
ubuntuRemoteImage:
type: docker:RemoteImage
name: ubuntu
properties:
name: ubuntu:precise
Import
Example
Assuming you created a container
as follows #!/bin/bash docker run --name foo -p8080:80 -d nginx prints the container ID 9a550c0f0163d39d77222d3efd58701b625d47676c25c686c95b5b92d1cba6fd you provide the definition for the resource as follows terraform resource "docker_container" "foo" { name = "foo" image = "nginx" ports { internal = "80" external = "8080" } } then the import command is as follows #!/bin/bash
$ pulumi import docker:index/container:Container foo 9a550c0f0163d39d77222d3efd58701b625d47676c25c686c95b5b92d1cba6fd
Constructors
Properties
Add or drop certrain linux capabilities.
Cgroup namespace mode to use for the container. Possible values are: private
, host
.
The total number of milliseconds to wait for the container to reach status 'running'
If defined will attempt to stop the container before destroying. Container will be destroyed after n
seconds or on successful stop.
Bind devices to the container.
DNS search domains that are used when bare unqualified hostnames are used inside of the container.
Domain name of the container.
The command to use as the Entrypoint for the container. The Entrypoint allows you to configure a container to run as an executable. For example, to run /usr/bin/myprogram
when starting a container, set the entrypoint to be "/usr/bin/myprogram"]
.
A test to perform to check that the container is healthy
Additional hosts to add to the container.
User-defined key/value metadata
The maximum amount of times to an attempt a restart when restart
is set to 'on-failure'.
The total memory limit (memory + swap) for the container in MBs. This setting may compute to -1
after pulumi up
if the target host doesn't support memory swap, when that is the case docker will use a soft limitation.
Specification for mounts to be added to containers created as part of the service.
Network mode of the container. See https://docs.docker.com/engine/network/ for more information.
The networks the container is attached to
Publish a container's port(s) to the host.
If true
, the container runs in privileged mode.
Publish all ports of the container.
If true
, it will remove anonymous volumes associated with the container. Defaults to true
.
List of string values to customize labels for MLS systems, such as SELinux. See https://docs.docker.com/engine/reference/run/#security-configuration.
Signal to stop a container (default SIGTERM
).
Timeout (in seconds) to stop a container.
Key/value pairs for the storage driver options, e.g. size
: 120G
Ulimit options to add.
Specifies files to upload to the container before starting it. Only one of content
or content_base64
can be set and at least one of them has to be set.
Sets the usernamespace mode for the container when usernamespace remapping option is enabled.
Spec for mounting volumes in the container.
The timeout in seconds to wait the container to be healthy after creation. Defaults to 60
.
The working directory for commands to run in.