Join us at the Cloud Engineering Summit on October 20th for a free day of learning. Save your spot.

Service

Import

Example Assuming you created a service as follows #!/bin/bash docker service create –name foo -p 8080:80 nginx # prints th ID 4pcphbxkfn2rffhbhe6czytgi you provide the definition for the resource as follows terraform resource “docker_service” “foo” {

name = “foo”

task_spec {

container_spec {

image = “nginx”

}

}

endpoint_spec {

ports {

target_port

= “80”

published_port = “8080”

}

} } then the import command is as follows #!/bin/bash

 $ pulumi import docker:index/service:Service foo 4pcphbxkfn2rffhbhe6czytgi

Create a Service Resource

new Service(name: string, args: ServiceArgs, opts?: CustomResourceOptions);
@overload
def Service(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            auth: Optional[ServiceAuthArgs] = None,
            converge_config: Optional[ServiceConvergeConfigArgs] = None,
            endpoint_spec: Optional[ServiceEndpointSpecArgs] = None,
            labels: Optional[Sequence[ServiceLabelArgs]] = None,
            mode: Optional[ServiceModeArgs] = None,
            name: Optional[str] = None,
            rollback_config: Optional[ServiceRollbackConfigArgs] = None,
            task_spec: Optional[ServiceTaskSpecArgs] = None,
            update_config: Optional[ServiceUpdateConfigArgs] = None)
@overload
def Service(resource_name: str,
            args: ServiceArgs,
            opts: Optional[ResourceOptions] = None)
func NewService(ctx *Context, name string, args ServiceArgs, opts ...ResourceOption) (*Service, error)
public Service(string name, ServiceArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args ServiceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args ServiceArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args ServiceArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ServiceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Service Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The Service resource accepts the following input properties:

TaskSpec ServiceTaskSpecArgs
User modifiable task configuration
Auth ServiceAuthArgs
Configuration for the authentication for pulling the images of the service
ConvergeConfig ServiceConvergeConfigArgs
A configuration to ensure that a service converges aka reaches the desired that of all task up and running
EndpointSpec ServiceEndpointSpecArgs
Properties that can be configured to access and load balance a service
Labels List<ServiceLabelArgs>
User-defined key/value metadata
Mode ServiceModeArgs
Scheduling mode for the service
Name string
Name of the service
RollbackConfig ServiceRollbackConfigArgs
Specification for the rollback strategy of the service
UpdateConfig ServiceUpdateConfigArgs
Specification for the update strategy of the service
TaskSpec ServiceTaskSpecArgs
User modifiable task configuration
Auth ServiceAuthArgs
Configuration for the authentication for pulling the images of the service
ConvergeConfig ServiceConvergeConfigArgs
A configuration to ensure that a service converges aka reaches the desired that of all task up and running
EndpointSpec ServiceEndpointSpecArgs
Properties that can be configured to access and load balance a service
Labels []ServiceLabelArgs
User-defined key/value metadata
Mode ServiceModeArgs
Scheduling mode for the service
Name string
Name of the service
RollbackConfig ServiceRollbackConfigArgs
Specification for the rollback strategy of the service
UpdateConfig ServiceUpdateConfigArgs
Specification for the update strategy of the service
taskSpec ServiceTaskSpecArgs
User modifiable task configuration
auth ServiceAuthArgs
Configuration for the authentication for pulling the images of the service
convergeConfig ServiceConvergeConfigArgs
A configuration to ensure that a service converges aka reaches the desired that of all task up and running
endpointSpec ServiceEndpointSpecArgs
Properties that can be configured to access and load balance a service
labels ServiceLabelArgs[]
User-defined key/value metadata
mode ServiceModeArgs
Scheduling mode for the service
name string
Name of the service
rollbackConfig ServiceRollbackConfigArgs
Specification for the rollback strategy of the service
updateConfig ServiceUpdateConfigArgs
Specification for the update strategy of the service
task_spec ServiceTaskSpecArgs
User modifiable task configuration
auth ServiceAuthArgs
Configuration for the authentication for pulling the images of the service
converge_config ServiceConvergeConfigArgs
A configuration to ensure that a service converges aka reaches the desired that of all task up and running
endpoint_spec ServiceEndpointSpecArgs
Properties that can be configured to access and load balance a service
labels Sequence[ServiceLabelArgs]
User-defined key/value metadata
mode ServiceModeArgs
Scheduling mode for the service
name str
Name of the service
rollback_config ServiceRollbackConfigArgs
Specification for the rollback strategy of the service
update_config ServiceUpdateConfigArgs
Specification for the update strategy of the service

Outputs

All input properties are implicitly available as output properties. Additionally, the Service resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing Service Resource

Get an existing Service resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ServiceState, opts?: CustomResourceOptions): Service
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        auth: Optional[ServiceAuthArgs] = None,
        converge_config: Optional[ServiceConvergeConfigArgs] = None,
        endpoint_spec: Optional[ServiceEndpointSpecArgs] = None,
        labels: Optional[Sequence[ServiceLabelArgs]] = None,
        mode: Optional[ServiceModeArgs] = None,
        name: Optional[str] = None,
        rollback_config: Optional[ServiceRollbackConfigArgs] = None,
        task_spec: Optional[ServiceTaskSpecArgs] = None,
        update_config: Optional[ServiceUpdateConfigArgs] = None) -> Service
func GetService(ctx *Context, name string, id IDInput, state *ServiceState, opts ...ResourceOption) (*Service, error)
public static Service Get(string name, Input<string> id, ServiceState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Auth ServiceAuthArgs
Configuration for the authentication for pulling the images of the service
ConvergeConfig ServiceConvergeConfigArgs
A configuration to ensure that a service converges aka reaches the desired that of all task up and running
EndpointSpec ServiceEndpointSpecArgs
Properties that can be configured to access and load balance a service
Labels List<ServiceLabelArgs>
User-defined key/value metadata
Mode ServiceModeArgs
Scheduling mode for the service
Name string
Name of the service
RollbackConfig ServiceRollbackConfigArgs
Specification for the rollback strategy of the service
TaskSpec ServiceTaskSpecArgs
User modifiable task configuration
UpdateConfig ServiceUpdateConfigArgs
Specification for the update strategy of the service
Auth ServiceAuthArgs
Configuration for the authentication for pulling the images of the service
ConvergeConfig ServiceConvergeConfigArgs
A configuration to ensure that a service converges aka reaches the desired that of all task up and running
EndpointSpec ServiceEndpointSpecArgs
Properties that can be configured to access and load balance a service
Labels []ServiceLabelArgs
User-defined key/value metadata
Mode ServiceModeArgs
Scheduling mode for the service
Name string
Name of the service
RollbackConfig ServiceRollbackConfigArgs
Specification for the rollback strategy of the service
TaskSpec ServiceTaskSpecArgs
User modifiable task configuration
UpdateConfig ServiceUpdateConfigArgs
Specification for the update strategy of the service
auth ServiceAuthArgs
Configuration for the authentication for pulling the images of the service
convergeConfig ServiceConvergeConfigArgs
A configuration to ensure that a service converges aka reaches the desired that of all task up and running
endpointSpec ServiceEndpointSpecArgs
Properties that can be configured to access and load balance a service
labels ServiceLabelArgs[]
User-defined key/value metadata
mode ServiceModeArgs
Scheduling mode for the service
name string
Name of the service
rollbackConfig ServiceRollbackConfigArgs
Specification for the rollback strategy of the service
taskSpec ServiceTaskSpecArgs
User modifiable task configuration
updateConfig ServiceUpdateConfigArgs
Specification for the update strategy of the service
auth ServiceAuthArgs
Configuration for the authentication for pulling the images of the service
converge_config ServiceConvergeConfigArgs
A configuration to ensure that a service converges aka reaches the desired that of all task up and running
endpoint_spec ServiceEndpointSpecArgs
Properties that can be configured to access and load balance a service
labels Sequence[ServiceLabelArgs]
User-defined key/value metadata
mode ServiceModeArgs
Scheduling mode for the service
name str
Name of the service
rollback_config ServiceRollbackConfigArgs
Specification for the rollback strategy of the service
task_spec ServiceTaskSpecArgs
User modifiable task configuration
update_config ServiceUpdateConfigArgs
Specification for the update strategy of the service

Supporting Types

ServiceAuth

ServerAddress string
Password string
Username string
ServerAddress string
Password string
Username string
serverAddress string
password string
username string
server_address str
password str
username str

ServiceConvergeConfig

Delay string
Timeout string
Delay string
Timeout string
delay string
timeout string
delay str
timeout str

ServiceEndpointSpec

Mode string
Ports List<ServiceEndpointSpecPort>
Mode string
Ports []ServiceEndpointSpecPort
mode string
ports ServiceEndpointSpecPort[]
mode str
ports Sequence[ServiceEndpointSpecPort]

ServiceEndpointSpecPort

TargetPort int
Name string
Protocol string
PublishMode string
PublishedPort int
TargetPort int
Name string
Protocol string
PublishMode string
PublishedPort int
targetPort number
name string
protocol string
publishMode string
publishedPort number
target_port int
name str
protocol str
publish_mode str
published_port int

ServiceLabel

Label string
Value string
Label string
Value string
label string
value string
label str
value str

ServiceMode

Global bool
Replicated ServiceModeReplicated
Global bool
Replicated ServiceModeReplicated
global boolean
replicated ServiceModeReplicated
global_ bool
replicated ServiceModeReplicated

ServiceModeReplicated

Replicas int
Replicas int
replicas number
replicas int

ServiceRollbackConfig

Delay string
FailureAction string
MaxFailureRatio string
Monitor string
Order string
Parallelism int
Delay string
FailureAction string
MaxFailureRatio string
Monitor string
Order string
Parallelism int
delay string
failureAction string
maxFailureRatio string
monitor string
order string
parallelism number
delay str
failure_action str
max_failure_ratio str
monitor str
order str
parallelism int

ServiceTaskSpec

ContainerSpec ServiceTaskSpecContainerSpec
ForceUpdate int
LogDriver ServiceTaskSpecLogDriver
Networks List<string>
Placement ServiceTaskSpecPlacement
Resources ServiceTaskSpecResources
RestartPolicy ServiceTaskSpecRestartPolicy
Runtime string
ContainerSpec ServiceTaskSpecContainerSpec
ForceUpdate int
LogDriver ServiceTaskSpecLogDriver
Networks []string
Placement ServiceTaskSpecPlacement
Resources ServiceTaskSpecResources
RestartPolicy ServiceTaskSpecRestartPolicy
Runtime string
containerSpec ServiceTaskSpecContainerSpec
forceUpdate number
logDriver ServiceTaskSpecLogDriver
networks string[]
placement ServiceTaskSpecPlacement
resources ServiceTaskSpecResources
restartPolicy ServiceTaskSpecRestartPolicy
runtime string
container_spec ServiceTaskSpecContainerSpec
force_update int
log_driver ServiceTaskSpecLogDriver
networks Sequence[str]
placement ServiceTaskSpecPlacement
resources ServiceTaskSpecResources
restart_policy ServiceTaskSpecRestartPolicy
runtime str

ServiceTaskSpecContainerSpec

Image string
Args List<string>
Commands List<string>
Configs List<ServiceTaskSpecContainerSpecConfig>
Dir string
DnsConfig ServiceTaskSpecContainerSpecDnsConfig
Env Dictionary<string, string>
Groups List<string>
Healthcheck ServiceTaskSpecContainerSpecHealthcheck
Hostname string
Hosts List<ServiceTaskSpecContainerSpecHost>
Isolation string
Labels List<ServiceTaskSpecContainerSpecLabel>
Mounts List<ServiceTaskSpecContainerSpecMount>
Privileges ServiceTaskSpecContainerSpecPrivileges
ReadOnly bool
Secrets List<ServiceTaskSpecContainerSpecSecret>
StopGracePeriod string
StopSignal string
User string
Image string
Args []string
Commands []string
Configs []ServiceTaskSpecContainerSpecConfig
Dir string
DnsConfig ServiceTaskSpecContainerSpecDnsConfig
Env map[string]string
Groups []string
Healthcheck ServiceTaskSpecContainerSpecHealthcheck
Hostname string
Hosts []ServiceTaskSpecContainerSpecHost
Isolation string
Labels []ServiceTaskSpecContainerSpecLabel
Mounts []ServiceTaskSpecContainerSpecMount
Privileges ServiceTaskSpecContainerSpecPrivileges
ReadOnly bool
Secrets []ServiceTaskSpecContainerSpecSecret
StopGracePeriod string
StopSignal string
User string
image string
args string[]
commands string[]
configs ServiceTaskSpecContainerSpecConfig[]
dir string
dnsConfig ServiceTaskSpecContainerSpecDnsConfig
env {[key: string]: string}
groups string[]
healthcheck ServiceTaskSpecContainerSpecHealthcheck
hostname string
hosts ServiceTaskSpecContainerSpecHost[]
isolation string
labels ServiceTaskSpecContainerSpecLabel[]
mounts ServiceTaskSpecContainerSpecMount[]
privileges ServiceTaskSpecContainerSpecPrivileges
readOnly boolean
secrets ServiceTaskSpecContainerSpecSecret[]
stopGracePeriod string
stopSignal string
user string
image str
args Sequence[str]
commands Sequence[str]
configs Sequence[ServiceTaskSpecContainerSpecConfig]
dir str
dns_config ServiceTaskSpecContainerSpecDnsConfig
env Mapping[str, str]
groups Sequence[str]
healthcheck ServiceTaskSpecContainerSpecHealthcheck
hostname str
hosts Sequence[ServiceTaskSpecContainerSpecHost]
isolation str
labels Sequence[ServiceTaskSpecContainerSpecLabel]
mounts Sequence[ServiceTaskSpecContainerSpecMount]
privileges ServiceTaskSpecContainerSpecPrivileges
read_only bool
secrets Sequence[ServiceTaskSpecContainerSpecSecret]
stop_grace_period str
stop_signal str
user str

ServiceTaskSpecContainerSpecConfig

ConfigId string
FileName string
ConfigName string
FileGid string
FileMode int
FileUid string
ConfigId string
FileName string
ConfigName string
FileGid string
FileMode int
FileUid string
configId string
fileName string
configName string
fileGid string
fileMode number
fileUid string
config_id str
file_name str
config_name str
file_gid str
file_mode int
file_uid str

ServiceTaskSpecContainerSpecDnsConfig

Nameservers List<string>
Options List<string>
Searches List<string>
Nameservers []string
Options []string
Searches []string
nameservers string[]
options string[]
searches string[]
nameservers Sequence[str]
options Sequence[str]
searches Sequence[str]

ServiceTaskSpecContainerSpecHealthcheck

Tests List<string>
Interval string
Retries int
StartPeriod string
Timeout string
Tests []string
Interval string
Retries int
StartPeriod string
Timeout string
tests string[]
interval string
retries number
startPeriod string
timeout string
tests Sequence[str]
interval str
retries int
start_period str
timeout str

ServiceTaskSpecContainerSpecHost

Host string
Ip string
Host string
Ip string
host string
ip string
host str
ip str

ServiceTaskSpecContainerSpecLabel

Label string
Value string
Label string
Value string
label string
value string
label str
value str

ServiceTaskSpecContainerSpecMount

Target string
Type string
BindOptions ServiceTaskSpecContainerSpecMountBindOptions
ReadOnly bool
Source string
TmpfsOptions ServiceTaskSpecContainerSpecMountTmpfsOptions
VolumeOptions ServiceTaskSpecContainerSpecMountVolumeOptions
Target string
Type string
BindOptions ServiceTaskSpecContainerSpecMountBindOptions
ReadOnly bool
Source string
TmpfsOptions ServiceTaskSpecContainerSpecMountTmpfsOptions
VolumeOptions ServiceTaskSpecContainerSpecMountVolumeOptions
target string
type string
bindOptions ServiceTaskSpecContainerSpecMountBindOptions
readOnly boolean
source string
tmpfsOptions ServiceTaskSpecContainerSpecMountTmpfsOptions
volumeOptions ServiceTaskSpecContainerSpecMountVolumeOptions
target str
type str
bind_options ServiceTaskSpecContainerSpecMountBindOptions
read_only bool
source str
tmpfs_options ServiceTaskSpecContainerSpecMountTmpfsOptions
volume_options ServiceTaskSpecContainerSpecMountVolumeOptions

ServiceTaskSpecContainerSpecMountBindOptions

Propagation string
Propagation string
propagation string
propagation str

ServiceTaskSpecContainerSpecMountTmpfsOptions

Mode int
SizeBytes int
Mode int
SizeBytes int
mode number
sizeBytes number
mode int
size_bytes int

ServiceTaskSpecContainerSpecMountVolumeOptions

DriverName string
DriverOptions Dictionary<string, string>
Labels List<ServiceTaskSpecContainerSpecMountVolumeOptionsLabel>
NoCopy bool
DriverName string
DriverOptions map[string]string
Labels []ServiceTaskSpecContainerSpecMountVolumeOptionsLabel
NoCopy bool
driverName string
driverOptions {[key: string]: string}
labels ServiceTaskSpecContainerSpecMountVolumeOptionsLabel[]
noCopy boolean
driver_name str
driver_options Mapping[str, str]
labels Sequence[ServiceTaskSpecContainerSpecMountVolumeOptionsLabel]
no_copy bool

ServiceTaskSpecContainerSpecMountVolumeOptionsLabel

Label string
Value string
Label string
Value string
label string
value string
label str
value str

ServiceTaskSpecContainerSpecPrivileges

CredentialSpec ServiceTaskSpecContainerSpecPrivilegesCredentialSpec
SeLinuxContext ServiceTaskSpecContainerSpecPrivilegesSeLinuxContext
CredentialSpec ServiceTaskSpecContainerSpecPrivilegesCredentialSpec
SeLinuxContext ServiceTaskSpecContainerSpecPrivilegesSeLinuxContext
credentialSpec ServiceTaskSpecContainerSpecPrivilegesCredentialSpec
seLinuxContext ServiceTaskSpecContainerSpecPrivilegesSeLinuxContext
credential_spec ServiceTaskSpecContainerSpecPrivilegesCredentialSpec
se_linux_context ServiceTaskSpecContainerSpecPrivilegesSeLinuxContext

ServiceTaskSpecContainerSpecPrivilegesCredentialSpec

File string
Registry string
File string
Registry string
file string
registry string
file str
registry str

ServiceTaskSpecContainerSpecPrivilegesSeLinuxContext

Disable bool
Level string
Role string
Type string
User string
Disable bool
Level string
Role string
Type string
User string
disable boolean
level string
role string
type string
user string
disable bool
level str
role str
type str
user str

ServiceTaskSpecContainerSpecSecret

FileName string
SecretId string
FileGid string
FileMode int
FileUid string
SecretName string
FileName string
SecretId string
FileGid string
FileMode int
FileUid string
SecretName string
fileName string
secretId string
fileGid string
fileMode number
fileUid string
secretName string
file_name str
secret_id str
file_gid str
file_mode int
file_uid str
secret_name str

ServiceTaskSpecLogDriver

Name string
Options Dictionary<string, string>
Name string
Options map[string]string
name string
options {[key: string]: string}
name str
options Mapping[str, str]

ServiceTaskSpecPlacement

Constraints List<string>
MaxReplicas int
Platforms List<ServiceTaskSpecPlacementPlatform>
Prefs List<string>
Constraints []string
MaxReplicas int
Platforms []ServiceTaskSpecPlacementPlatform
Prefs []string
constraints string[]
maxReplicas number
platforms ServiceTaskSpecPlacementPlatform[]
prefs string[]
constraints Sequence[str]
max_replicas int
platforms Sequence[ServiceTaskSpecPlacementPlatform]
prefs Sequence[str]

ServiceTaskSpecPlacementPlatform

Architecture string
Os string
Architecture string
Os string
architecture string
os string
architecture str
os str

ServiceTaskSpecResources

Limits ServiceTaskSpecResourcesLimits
Reservation ServiceTaskSpecResourcesReservation
Limits ServiceTaskSpecResourcesLimits
Reservation ServiceTaskSpecResourcesReservation
limits ServiceTaskSpecResourcesLimits
reservation ServiceTaskSpecResourcesReservation
limits ServiceTaskSpecResourcesLimits
reservation ServiceTaskSpecResourcesReservation

ServiceTaskSpecResourcesLimits

MemoryBytes int
NanoCpus int
MemoryBytes int
NanoCpus int
memoryBytes number
nanoCpus number
memory_bytes int
nano_cpus int

ServiceTaskSpecResourcesReservation

GenericResources ServiceTaskSpecResourcesReservationGenericResources
MemoryBytes int
NanoCpus int
GenericResources ServiceTaskSpecResourcesReservationGenericResources
MemoryBytes int
NanoCpus int
genericResources ServiceTaskSpecResourcesReservationGenericResources
memoryBytes number
nanoCpus number
generic_resources ServiceTaskSpecResourcesReservationGenericResources
memory_bytes int
nano_cpus int

ServiceTaskSpecResourcesReservationGenericResources

DiscreteResourcesSpecs List<string>
NamedResourcesSpecs List<string>
DiscreteResourcesSpecs []string
NamedResourcesSpecs []string
discreteResourcesSpecs string[]
namedResourcesSpecs string[]
discrete_resources_specs Sequence[str]
named_resources_specs Sequence[str]

ServiceTaskSpecRestartPolicy

Condition string
Delay string
MaxAttempts int
Window string
Condition string
Delay string
MaxAttempts int
Window string
condition string
delay string
maxAttempts number
window string
condition str
delay str
max_attempts int
window str

ServiceUpdateConfig

Delay string
FailureAction string
MaxFailureRatio string
Monitor string
Order string
Parallelism int
Delay string
FailureAction string
MaxFailureRatio string
Monitor string
Order string
Parallelism int
delay string
failureAction string
maxFailureRatio string
monitor string
order string
parallelism number
delay str
failure_action str
max_failure_ratio str
monitor str
order str
parallelism int

Package Details

Repository
https://github.com/pulumi/pulumi-docker
License
Apache-2.0
Notes
This Pulumi package is based on the docker Terraform Provider.