Container

class Container : KotlinCustomResource

Manages the lifecycle of a Docker container.

Example Usage

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) {
var ubuntuRemoteImage = new RemoteImage("ubuntuRemoteImage", RemoteImageArgs.builder()
.name("ubuntu:precise")
.build());
var ubuntuContainer = new Container("ubuntuContainer", ContainerArgs.builder()
.image(ubuntuRemoteImage.imageId())
.build());
}
}

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

Properties

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

If true attach to the container after its creation and waits the end of its execution. Defaults to false.

Link copied to clipboard
val bridge: Output<String>

The network bridge of the container as read from its NetworkSettings.

Link copied to clipboard

Add or drop certrain linux capabilities.

Link copied to clipboard
val command: Output<List<String>>

The command to use to start the container. For example, to run /usr/bin/myprogram -f baz.conf set the command to be ["/usr/bin/myprogram","-","baz&#46;con"].

Link copied to clipboard
val containerLogs: Output<String>

The logs of the container if its execution is done (attach must be disabled).

Link copied to clipboard

The total number of milliseconds to wait for the container to reach status 'running'

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

A comma-separated list or hyphen-separated range of CPUs a container can use, e.g. 0-1.

Link copied to clipboard
val cpuShares: Output<Int>?

CPU shares (relative weight) for the container.

Link copied to clipboard
val destroyGraceSeconds: Output<Int>?

If defined will attempt to stop the container before destroying. Container will be destroyed after n seconds or on successful stop.

Link copied to clipboard

Bind devices to the container.

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

DNS servers to use.

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

DNS options used by the DNS provider(s), see resolv.conf documentation for valid list of options.

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

DNS search domains that are used when bare unqualified hostnames are used inside of the container.

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

Domain name of the container.

Link copied to clipboard
val entrypoints: Output<List<String>>

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/myprogra"].

Link copied to clipboard
val envs: Output<List<String>>

Environment variables to set in the form of KEY=VALUE, e.g. DEBUG=0

Link copied to clipboard
val exitCode: Output<Int>

The exit code of the container if its execution is done (must_run must be disabled).

Link copied to clipboard
val gateway: Output<String>

The network gateway of the container.

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

GPU devices to add to the container. Currently, only the value all is supported. Passing any other value will result in unexpected behavior.

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

Additional groups for the container user

Link copied to clipboard

A test to perform to check that the container is healthy

Link copied to clipboard
val hostname: Output<String>

Hostname of the container.

Link copied to clipboard
val hosts: Output<List<ContainerHost>>?

Additional hosts to add to the container.

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

The ID of the image to back this container. The easiest way to get this value is to use the docker.RemoteImage resource as is shown in the example.

Link copied to clipboard
val init: Output<Boolean>

Configured whether an init process should be injected for this container. If unset this will default to the dockerd defaults.

Link copied to clipboard
val ipAddress: Output<String>

The IP address of the container.

Link copied to clipboard
val ipcMode: Output<String>

IPC sharing mode for the container. Possible values are: none, private, shareable, container:<name|id> or host.

Link copied to clipboard
val ipPrefixLength: Output<Int>

The IP prefix length of the container.

Link copied to clipboard
val labels: Output<List<ContainerLabel>>

User-defined key/value metadata

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

Set of links for link based connectivity between containers that are running on the same host.

Link copied to clipboard
val logDriver: Output<String>

The logging driver to use for the container.

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

Key/value pairs to use as options for the logging driver.

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

Save the container logs (attach must be enabled). Defaults to false.

Link copied to clipboard
val maxRetryCount: Output<Int>?

The maximum amount of times to an attempt a restart when restart is set to 'on-failure'.

Link copied to clipboard
val memory: Output<Int>?

The memory limit for the container in MBs.

Link copied to clipboard
val memorySwap: Output<Int>?

The total memory limit (memory + swap) for the container in MBs. This setting may compute to -1 after terraform apply if the target host doesn't support memory swap, when that is the case docker will use a soft limitation.

Link copied to clipboard
val mounts: Output<List<ContainerMount>>?

Specification for mounts to be added to containers created as part of the service.

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

If true, then the Docker container will be kept running. If false, then as long as the container exists, Terraform assumes it is successful. Defaults to true.

Link copied to clipboard
val name: Output<String>

The name of the container.

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

Set an alias for the container in all specified networks

Link copied to clipboard

The data of the networks the container is connected to.

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

Network mode of the container.

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

ID of the networks in which the container is.

Link copied to clipboard

The networks the container is attached to

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

he PID (Process) Namespace mode for the container. Either container:<name|id> or host.

Link copied to clipboard
val ports: Output<List<ContainerPort>>?

Publish a container's port(s) to the host.

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

If true, the container runs in privileged mode.

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

Publish all ports of the container.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val readOnly: Output<Boolean>?

If true, the container will be started as readonly. Defaults to false.

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

If true, it will remove anonymous volumes associated with the container. Defaults to true.

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

The restart policy for the container. Must be one of 'no', 'on-failure', 'always', 'unless-stopped'. Defaults to no.

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

If true, then the container will be automatically removed when it exits. Defaults to false.

Link copied to clipboard
val runtime: Output<String>

Runtime to use for the container.

Link copied to clipboard
val securityOpts: Output<List<String>>

List of string values to customize labels for MLS systems, such as SELinux. See https://docs.docker.com/engine/reference/run/#security-configuration.

Link copied to clipboard
val shmSize: Output<Int>

Size of /dev/shm in MBs.

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

If true, then the Docker container will be started after creation. If false, then the container is only created. Defaults to true.

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

If true, keep STDIN open even if not attached (docker run -i). Defaults to false.

Link copied to clipboard
val stopSignal: Output<String>

Signal to stop a container (default SIGTERM).

Link copied to clipboard
val stopTimeout: Output<Int>

Timeout (in seconds) to stop a container.

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

Key/value pairs for the storage driver options, e.g. size: 120G

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

A map of kernel parameters (sysctls) to set in the container.

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

A map of container directories which should be replaced by tmpfs mounts, and their corresponding mount options.

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

If true, allocate a pseudo-tty (docker run -t). Defaults to false.

Link copied to clipboard

Ulimit options to add.

Link copied to clipboard

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.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val user: Output<String>?

User used for run the first process. Format is user or user:group which user and group can be passed literraly or by name.

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

Sets the usernamespace mode for the container when usernamespace remapping option is enabled.

Link copied to clipboard

Spec for mounting volumes in the container.

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

If true, then the Docker container is waited for being healthy state after creation. If false, then the container health state is not checked. Defaults to false.

Link copied to clipboard
val waitTimeout: Output<Int>?

The timeout in seconds to wait the container to be healthy after creation. Defaults to 60.

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

The working directory for commands to run in.