Deregisters an Amazon ECS container instance from the specified cluster. This instance is no longer available to run tasks.
If you intend to use the container instance for some other purpose after deregistration, you should stop all of the tasks running on the container instance before deregistration. That prevents any orphaned tasks from consuming resources.
Deregistering a container instance removes the instance from a cluster, but it does not terminate the EC2 instance. If you are finished using the instance, be sure to terminate it in the Amazon EC2 console to stop billing.
Note
If you terminate a running container instance, Amazon ECS automatically deregisters the instance from your cluster (stopped container instances or instances with disconnected agents are not automatically deregistered when terminated).
See also: AWS API Documentation
See ‘aws help’ for descriptions of global parameters.
deregister-container-instance
[--cluster <value>]
--container-instance <value>
[--force | --no-force]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
--cluster
(string)
The short name or full Amazon Resource Name (ARN) of the cluster that hosts the container instance to deregister. If you do not specify a cluster, the default cluster is assumed.
--container-instance
(string)
The container instance ID or full ARN of the container instance to deregister. The ARN contains the
arn:aws:ecs
namespace, followed by the Region of the container instance, the AWS account ID of the container instance owner, thecontainer-instance
namespace, and then the container instance ID. For example,arn:aws:ecs:region:aws_account_id:container-instance/container_instance_ID
.
--force
| --no-force
(boolean)
Forces the deregistration of the container instance. If you have tasks running on the container instance when you deregister it with the
force
option, these tasks remain running until you terminate the instance or the tasks stop through some other means, but they are orphaned (no longer monitored or accounted for by Amazon ECS). If an orphaned task on your container instance is part of an Amazon ECS service, then the service scheduler starts another copy of that task, on a different container instance if possible.Any containers in orphaned service tasks that are registered with a Classic Load Balancer or an Application Load Balancer target group are deregistered. They begin connection draining according to the settings on the load balancer or target group.
--cli-input-json
| --cli-input-yaml
(string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml
.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. Similarly, if provided yaml-input
it will print a sample input YAML that can be used with --cli-input-yaml
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
See ‘aws help’ for descriptions of global parameters.
To deregister a container instance from a cluster
The following deregister-container-instance
example deregisters a container instance from the specified cluster. If there are still tasks running in the container instance, you must either stop those tasks before deregistering, or use the --force
option.
aws ecs deregister-container-instance \
--cluster arn:aws:ecs:us-west-2:123456789012:cluster/MyCluster \
--container-instance arn:aws:ecs:us-west-2:123456789012:container-instance/a1b2c3d4-5678-90ab-cdef-11111EXAMPLE \
--force
Output:
{
"containerInstance": {
"remainingResources": [
{
"integerValue": 1024,
"doubleValue": 0.0,
"type": "INTEGER",
"longValue": 0,
"name": "CPU"
},
{
"integerValue": 985,
"doubleValue": 0.0,
"type": "INTEGER",
"longValue": 0,
"name": "MEMORY"
},
{
"type": "STRINGSET",
"integerValue": 0,
"name": "PORTS",
"stringSetValue": [
"22",
"2376",
"2375",
"51678",
"51679"
],
"longValue": 0,
"doubleValue": 0.0
},
{
"type": "STRINGSET",
"integerValue": 0,
"name": "PORTS_UDP",
"stringSetValue": [],
"longValue": 0,
"doubleValue": 0.0
}
],
"agentConnected": true,
"attributes": [
{
"name": "ecs.capability.secrets.asm.environment-variables"
},
{
"name": "com.amazonaws.ecs.capability.logging-driver.syslog"
},
{
"value": "ami-01a82c3fce2c3ba58",
"name": "ecs.ami-id"
},
{
"name": "ecs.capability.secrets.asm.bootstrap.log-driver"
},
{
"name": "com.amazonaws.ecs.capability.logging-driver.none"
},
{
"name": "ecs.capability.ecr-endpoint"
},
{
"name": "com.amazonaws.ecs.capability.logging-driver.json-file"
},
{
"value": "vpc-1234567890123467",
"name": "ecs.vpc-id"
},
{
"name": "ecs.capability.execution-role-awslogs"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"name": "ecs.capability.docker-plugin.local"
},
{
"name": "ecs.capability.task-eni"
},
{
"name": "ecs.capability.task-cpu-mem-limit"
},
{
"name": "ecs.capability.secrets.ssm.bootstrap.log-driver"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.30"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.31"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.32"
},
{
"name": "ecs.capability.execution-role-ecr-pull"
},
{
"name": "ecs.capability.container-health-check"
},
{
"value": "subnet-1234567890123467",
"name": "ecs.subnet-id"
},
{
"value": "us-west-2a",
"name": "ecs.availability-zone"
},
{
"value": "t2.micro",
"name": "ecs.instance-type"
},
{
"name": "com.amazonaws.ecs.capability.task-iam-role-network-host"
},
{
"name": "ecs.capability.aws-appmesh"
},
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.24"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.25"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.26"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.27"
},
{
"name": "com.amazonaws.ecs.capability.privileged-container"
},
{
"name": "ecs.capability.container-ordering"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.28"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
},
{
"value": "x86_64",
"name": "ecs.cpu-architecture"
},
{
"value": "93f43776-2018.10.0",
"name": "ecs.capability.cni-plugin-version"
},
{
"name": "ecs.capability.secrets.ssm.environment-variables"
},
{
"name": "ecs.capability.pid-ipc-namespace-sharing"
},
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"value": "linux",
"name": "ecs.os-type"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.20"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.22"
},
{
"name": "ecs.capability.task-eia"
},
{
"name": "ecs.capability.private-registry-authentication.secretsmanager"
},
{
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.23"
}
],
"pendingTasksCount": 0,
"tags": [],
"containerInstanceArn": "arn:aws:ecs:us-west-2:123456789012:container-instance/a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
"registeredResources": [
{
"integerValue": 1024,
"doubleValue": 0.0,
"type": "INTEGER",
"longValue": 0,
"name": "CPU"
},
{
"integerValue": 985,
"doubleValue": 0.0,
"type": "INTEGER",
"longValue": 0,
"name": "MEMORY"
},
{
"type": "STRINGSET",
"integerValue": 0,
"name": "PORTS",
"stringSetValue": [
"22",
"2376",
"2375",
"51678",
"51679"
],
"longValue": 0,
"doubleValue": 0.0
},
{
"type": "STRINGSET",
"integerValue": 0,
"name": "PORTS_UDP",
"stringSetValue": [],
"longValue": 0,
"doubleValue": 0.0
}
],
"status": "INACTIVE",
"registeredAt": 1557768075.681,
"version": 4,
"versionInfo": {
"agentVersion": "1.27.0",
"agentHash": "aabe65ee",
"dockerVersion": "DockerVersion: 18.06.1-ce"
},
"attachments": [],
"runningTasksCount": 0,
"ec2InstanceId": "i-12345678901234678"
}
}
For more information, see Deregister a Container Instance in the ECS Developer Guide.
containerInstance -> (structure)
The container instance that was deregistered.
containerInstanceArn -> (string)
The Amazon Resource Name (ARN) of the container instance. The ARN contains the
arn:aws:ecs
namespace, followed by the Region of the container instance, the AWS account ID of the container instance owner, thecontainer-instance
namespace, and then the container instance ID. For example,arn:aws:ecs:region:aws_account_id:container-instance/container_instance_ID
.ec2InstanceId -> (string)
The EC2 instance ID of the container instance.
capacityProviderName -> (string)
The capacity provider associated with the container instance.
version -> (long)
The version counter for the container instance. Every time a container instance experiences a change that triggers a CloudWatch event, the version counter is incremented. If you are replicating your Amazon ECS container instance state with CloudWatch Events, you can compare the version of a container instance reported by the Amazon ECS APIs with the version reported in CloudWatch Events for the container instance (inside the
detail
object) to verify that the version in your event stream is current.versionInfo -> (structure)
The version information for the Amazon ECS container agent and Docker daemon running on the container instance.
agentVersion -> (string)
The version number of the Amazon ECS container agent.
agentHash -> (string)
The Git commit hash for the Amazon ECS container agent build on the amazon-ecs-agent GitHub repository.
dockerVersion -> (string)
The Docker version running on the container instance.
remainingResources -> (list)
For CPU and memory resource types, this parameter describes the remaining CPU and memory that has not already been allocated to tasks and is therefore available for new tasks. For port resource types, this parameter describes the ports that were reserved by the Amazon ECS container agent (at instance registration time) and any task containers that have reserved port mappings on the host (with the
host
orbridge
network mode). Any port that is not specified here is available for new tasks.(structure)
Describes the resources available for a container instance.
name -> (string)
The name of the resource, such as
CPU
,MEMORY
,PORTS
,PORTS_UDP
, or a user-defined resource.type -> (string)
The type of the resource, such as
INTEGER
,DOUBLE
,LONG
, orSTRINGSET
.doubleValue -> (double)
When the
doubleValue
type is set, the value of the resource must be a double precision floating-point type.longValue -> (long)
When the
longValue
type is set, the value of the resource must be an extended precision floating-point type.integerValue -> (integer)
When the
integerValue
type is set, the value of the resource must be an integer.stringSetValue -> (list)
When the
stringSetValue
type is set, the value of the resource must be a string type.(string)
registeredResources -> (list)
For CPU and memory resource types, this parameter describes the amount of each resource that was available on the container instance when the container agent registered it with Amazon ECS. This value represents the total amount of CPU and memory that can be allocated on this container instance to tasks. For port resource types, this parameter describes the ports that were reserved by the Amazon ECS container agent when it registered the container instance with Amazon ECS.
(structure)
Describes the resources available for a container instance.
name -> (string)
The name of the resource, such as
CPU
,MEMORY
,PORTS
,PORTS_UDP
, or a user-defined resource.type -> (string)
The type of the resource, such as
INTEGER
,DOUBLE
,LONG
, orSTRINGSET
.doubleValue -> (double)
When the
doubleValue
type is set, the value of the resource must be a double precision floating-point type.longValue -> (long)
When the
longValue
type is set, the value of the resource must be an extended precision floating-point type.integerValue -> (integer)
When the
integerValue
type is set, the value of the resource must be an integer.stringSetValue -> (list)
When the
stringSetValue
type is set, the value of the resource must be a string type.(string)
status -> (string)
The status of the container instance. The valid values are
REGISTERING
,REGISTRATION_FAILED
,ACTIVE
,INACTIVE
,DEREGISTERING
, orDRAINING
.If your account has opted in to the
awsvpcTrunking
account setting, then any newly registered container instance will transition to aREGISTERING
status while the trunk elastic network interface is provisioned for the instance. If the registration fails, the instance will transition to aREGISTRATION_FAILED
status. You can describe the container instance and see the reason for failure in thestatusReason
parameter. Once the container instance is terminated, the instance transitions to aDEREGISTERING
status while the trunk elastic network interface is deprovisioned. The instance then transitions to anINACTIVE
status.The
ACTIVE
status indicates that the container instance can accept tasks. TheDRAINING
indicates that new tasks are not placed on the container instance and any service tasks running on the container instance are removed if possible. For more information, see Container Instance Draining in the Amazon Elastic Container Service Developer Guide .statusReason -> (string)
The reason that the container instance reached its current status.
agentConnected -> (boolean)
This parameter returns
true
if the agent is connected to Amazon ECS. Registered instances with an agent that may be unhealthy or stopped returnfalse
. Only instances connected to an agent can accept placement requests.runningTasksCount -> (integer)
The number of tasks on the container instance that are in the
RUNNING
status.pendingTasksCount -> (integer)
The number of tasks on the container instance that are in the
PENDING
status.agentUpdateStatus -> (string)
The status of the most recent agent update. If an update has never been requested, this value is
NULL
.attributes -> (list)
The attributes set for the container instance, either by the Amazon ECS container agent at instance registration or manually with the PutAttributes operation.
(structure)
An attribute is a name-value pair associated with an Amazon ECS object. Attributes enable you to extend the Amazon ECS data model by adding custom metadata to your resources. For more information, see Attributes in the Amazon Elastic Container Service Developer Guide .
name -> (string)
The name of the attribute. The
name
must contain between 1 and 128 characters and name may contain letters (uppercase and lowercase), numbers, hyphens, underscores, forward slashes, back slashes, or periods.value -> (string)
The value of the attribute. The
value
must contain between 1 and 128 characters and may contain letters (uppercase and lowercase), numbers, hyphens, underscores, periods, at signs (@), forward slashes, back slashes, colons, or spaces. The value cannot contain any leading or trailing whitespace.targetType -> (string)
The type of the target with which to attach the attribute. This parameter is required if you use the short form ID for a resource instead of the full ARN.
targetId -> (string)
The ID of the target. You can specify the short form ID for a resource or the full Amazon Resource Name (ARN).
registeredAt -> (timestamp)
The Unix timestamp for when the container instance was registered.
attachments -> (list)
The resources attached to a container instance, such as elastic network interfaces.
(structure)
An object representing a container instance or task attachment.
id -> (string)
The unique identifier for the attachment.
type -> (string)
The type of the attachment, such as
ElasticNetworkInterface
.status -> (string)
The status of the attachment. Valid values are
PRECREATED
,CREATED
,ATTACHING
,ATTACHED
,DETACHING
,DETACHED
, andDELETED
.details -> (list)
Details of the attachment. For elastic network interfaces, this includes the network interface ID, the MAC address, the subnet ID, and the private IPv4 address.
(structure)
A key-value pair object.
name -> (string)
The name of the key-value pair. For environment variables, this is the name of the environment variable.
value -> (string)
The value of the key-value pair. For environment variables, this is the value of the environment variable.
tags -> (list)
The metadata that you apply to the container instance to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define.
The following basic restrictions apply to tags:
Maximum number of tags per resource - 50
For each resource, each tag key must be unique, and each tag key can have only one value.
Maximum key length - 128 Unicode characters in UTF-8
Maximum value length - 256 Unicode characters in UTF-8
If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.
Tag keys and values are case-sensitive.
Do not use
aws:
,AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.(structure)
The metadata that you apply to a resource to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define.
The following basic restrictions apply to tags:
Maximum number of tags per resource - 50
For each resource, each tag key must be unique, and each tag key can have only one value.
Maximum key length - 128 Unicode characters in UTF-8
Maximum value length - 256 Unicode characters in UTF-8
If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.
Tag keys and values are case-sensitive.
Do not use
aws:
,AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.key -> (string)
One part of a key-value pair that make up a tag. A
key
is a general label that acts like a category for more specific tag values.value -> (string)
The optional part of a key-value pair that make up a tag. A
value
acts as a descriptor within a tag category (key).