Class Container
Manages the lifecycle of a Docker container.
Example Usage
using Pulumi;
using Docker = Pulumi.Docker;
class MyStack : Stack
{
public MyStack()
{
// Find the latest Ubuntu precise image.
var ubuntuRemoteImage = new Docker.RemoteImage("ubuntuRemoteImage", new Docker.RemoteImageArgs
{
Name = "ubuntu:precise",
});
// Start a container
var ubuntuContainer = new Docker.Container("ubuntuContainer", new Docker.ContainerArgs
{
Image = ubuntuRemoteImage.Latest,
});
}
}
Inherited Members
Namespace: Pulumi.Docker
Assembly: Pulumi.Docker.dll
Syntax
public class Container : CustomResource
Constructors
View SourceContainer(String, ContainerArgs, CustomResourceOptions)
Create a Container resource with the given unique name, arguments, and options.
Declaration
public Container(string name, ContainerArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| ContainerArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceAttach
If true attach to the container after its creation and waits the end of his execution.
Declaration
public Output<bool?> Attach { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Bridge
The network bridge of the container as read from its NetworkSettings.
Declaration
public Output<string> Bridge { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Capabilities
See Capabilities below for details.
Declaration
public Output<ContainerCapabilities> Capabilities { get; }
Property Value
| Type | Description |
|---|---|
| Output<ContainerCapabilities> |
Command
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", "-f", "baz.conf"].
Declaration
public Output<ImmutableArray<string>> Command { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
ContainerLogs
The logs of the container if its execution is done (attach must be disabled).
Declaration
public Output<string> ContainerLogs { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
CpuSet
A comma-separated list or hyphen-separated range of CPUs a container can use, e.g. 0-1.
Declaration
public Output<string> CpuSet { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
CpuShares
CPU shares (relative weight) for the container.
Declaration
public Output<int?> CpuShares { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
DestroyGraceSeconds
If defined will attempt to stop the container before destroying. Container will be destroyed after n seconds or on successful stop.
Declaration
public Output<int?> DestroyGraceSeconds { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
Devices
See Devices below for details.
Declaration
public Output<ImmutableArray<ContainerDevice>> Devices { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ContainerDevice>> |
Dns
Set of DNS servers.
Declaration
public Output<ImmutableArray<string>> Dns { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
DnsOpts
Set of DNS options used by the DNS provider(s), see resolv.conf documentation for valid list of options.
Declaration
public Output<ImmutableArray<string>> DnsOpts { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
DnsSearches
Set of DNS search domains that are used when bare unqualified hostnames are used inside of the container.
Declaration
public Output<ImmutableArray<string>> DnsSearches { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
Domainname
Domain name of the container.
Declaration
public Output<string> Domainname { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Entrypoints
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"].
Declaration
public Output<ImmutableArray<string>> Entrypoints { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
Envs
Environment variables to set.
Declaration
public Output<ImmutableArray<string>> Envs { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
ExitCode
The exit code of the container if its execution is done (must_run must be disabled).
Declaration
public Output<int> ExitCode { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Int32> |
Gateway
Deprecated: Use network_data instead. The network gateway of the container as read from its
NetworkSettings.
Declaration
public Output<string> Gateway { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
GroupAdds
Add additional groups to run as.
Declaration
public Output<ImmutableArray<string>> GroupAdds { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
Healthcheck
See Healthcheck below for details.
Declaration
public Output<ContainerHealthcheck> Healthcheck { get; }
Property Value
| Type | Description |
|---|---|
| Output<ContainerHealthcheck> |
Hostname
Hostname of the container.
Declaration
public Output<string> Hostname { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Hosts
Hostname to add.
Declaration
public Output<ImmutableArray<ContainerHost>> Hosts { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ContainerHost>> |
Image
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 above.
Declaration
public Output<string> Image { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
IpAddress
Deprecated: Use network_data instead. The IP address of the container's first network it.
Declaration
public Output<string> IpAddress { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
IpcMode
IPC sharing mode for the container. Possible values are: none, private, shareable, container:<name|id> or host.
Declaration
public Output<string> IpcMode { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
IpPrefixLength
Deprecated: Use network_data instead. The IP prefix length of the container as read from its
NetworkSettings.
Declaration
public Output<int> IpPrefixLength { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Int32> |
Labels
Adding labels.
Declaration
public Output<ImmutableArray<ContainerLabel>> Labels { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ContainerLabel>> |
Links
Set of links for link based connectivity between containers that are running on the same host.
Declaration
public Output<ImmutableArray<string>> Links { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
LogDriver
The logging driver to use for the container. Defaults to "json-file".
Declaration
public Output<string> LogDriver { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
LogOpts
Key/value pairs to use as options for the logging driver.
Declaration
public Output<ImmutableDictionary<string, object>> LogOpts { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>> |
Logs
Save the container logs (attach must be enabled).
Declaration
public Output<bool?> Logs { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
MaxRetryCount
The maximum amount of times to an attempt
a restart when restart is set to "on-failure"
Declaration
public Output<int?> MaxRetryCount { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
Memory
The memory limit for the container in MBs.
Declaration
public Output<int?> Memory { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
MemorySwap
Declaration
public Output<int?> MemorySwap { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
Mounts
See Mounts below for details.
Declaration
public Output<ImmutableArray<ContainerMount>> Mounts { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ContainerMount>> |
MustRun
Declaration
public Output<bool?> MustRun { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Name
Declaration
public Output<string> Name { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
NetworkAliases
Network aliases of the container for user-defined networks only. Deprecated: use networks_advanced instead.
Declaration
public Output<ImmutableArray<string>> NetworkAliases { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
NetworkDatas
(Map of a block) The IP addresses of the container on each network. Key are the network names, values are the IP addresses.
Declaration
public Output<ImmutableArray<ContainerNetworkData>> NetworkDatas { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ContainerNetworkData>> |
NetworkMode
Network mode of the container.
Declaration
public Output<string> NetworkMode { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Networks
Id of the networks in which the
container is. Deprecated: use networks_advanced instead.
Declaration
public Output<ImmutableArray<string>> Networks { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
NetworksAdvanced
See Networks Advanced below for details. If this block has priority to the deprecated network_alias and network properties.
Declaration
public Output<ImmutableArray<ContainerNetworksAdvanced>> NetworksAdvanced { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ContainerNetworksAdvanced>> |
PidMode
The PID (Process) Namespace mode for the container. Either container:<name|id> or host.
Declaration
public Output<string> PidMode { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Ports
See Ports below for details.
Declaration
public Output<ImmutableArray<ContainerPort>> Ports { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ContainerPort>> |
Privileged
Run container in privileged mode.
Declaration
public Output<bool?> Privileged { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
PublishAllPorts
Publish all ports of the container.
Declaration
public Output<bool?> PublishAllPorts { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
ReadOnly
If true, this volume will be readonly. Defaults to false.
Declaration
public Output<bool?> ReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Restart
The restart policy for the container. Must be one of "no", "on-failure", "always", "unless-stopped".
Declaration
public Output<string> Restart { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Rm
Declaration
public Output<bool?> Rm { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
ShmSize
Size of /dev/shm in MBs.
Declaration
public Output<int> ShmSize { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Int32> |
Start
If true, then the Docker container will be started after creation. If false, then the container is only created.
Declaration
public Output<bool?> Start { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Sysctls
A map of kernel parameters (sysctls) to set in the container.
Declaration
public Output<ImmutableDictionary<string, object>> Sysctls { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>> |
Tmpfs
A map of container directories which should be replaced by tmpfs mounts, and their corresponding mount options.
Declaration
public Output<ImmutableDictionary<string, object>> Tmpfs { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>> |
Ulimits
See Ulimits below for details.
Declaration
public Output<ImmutableArray<ContainerUlimit>> Ulimits { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ContainerUlimit>> |
Uploads
See File Upload below for details.
Declaration
public Output<ImmutableArray<ContainerUpload>> Uploads { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ContainerUpload>> |
User
User used for run the first process. Format is
user or user:group which user and group can be passed literraly or
by name.
Declaration
public Output<string> User { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
UsernsMode
Sets the usernamespace mode for the container when usernamespace remapping option is enabled.
Declaration
public Output<string> UsernsMode { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Volumes
See Volumes below for details.
Declaration
public Output<ImmutableArray<ContainerVolume>> Volumes { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ContainerVolume>> |
WorkingDir
The working directory for commands to run in
Declaration
public Output<string> WorkingDir { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(String, Input<String>, ContainerState, CustomResourceOptions)
Get an existing Container resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static Container Get(string name, Input<string> id, ContainerState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| ContainerState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| Container |