Task Definition Port Mapping Args
The `PortMapping`
property specifies a port mapping. Port mappings allow containers to access ports on the host container instance to send or receive traffic. Port mappings are specified as part of the container definition. If you are using containers in a task with the `awsvpc`
or `host`
network mode, exposed ports should be specified using `containerPort`
. The `hostPort`
can be left blank or it must be the same value as the `containerPort`
. After a task reaches the `RUNNING`
status, manual and automatic host and container port assignments are visible in the `networkBindings`
section of DescribeTasks API responses.
Properties
The application protocol that's used for the port mapping. This parameter only applies to Service Connect. We recommend that you set this parameter to be consistent with the protocol that your application uses. If you set this parameter, Amazon ECS adds protocol-specific connection handling to the Service Connect proxy. If you set this parameter, Amazon ECS adds protocol-specific telemetry in the Amazon ECS console and CloudWatch. If you don't set a value for this parameter, then TCP is used. However, Amazon ECS doesn't add protocol-specific telemetry for TCP. `appProtocol`
is immutable in a Service Connect service. Updating this field requires a service deletion and redeployment. Tasks that run in a namespace can use short names to connect to services in the namespace. Tasks can connect to services across all of the clusters in the namespace. Tasks connect through a managed proxy container that collects logs and metrics for increased visibility. Only the tasks that Amazon ECS services create are supported with Service Connect. For more information, see Service Connect in the Amazon Elastic Container Service Developer Guide.
The port number on the container that's bound to the user-specified or automatically assigned host port. If you use containers in a task with the `awsvpc`
or `host`
network mode, specify the exposed ports using `containerPort`
. If you use containers in a task with the `bridge`
network mode and you specify a container port and not a host port, your container automatically receives a host port in the ephemeral port range. For more information, see `hostPort`
. Port mappings that are automatically assigned in this way do not count toward the 100 reserved ports limit of a container instance.
The port number range on the container that's bound to the dynamically mapped host port range. The following rules apply when you specify a `containerPortRange`
:
The name that's used for the port mapping. This parameter only applies to Service Connect. This parameter is the name that you use in the `serviceConnectConfiguration`
of a service. The name can include up to 64 characters. The characters can include lowercase letters, numbers, underscores (_), and hyphens (-). The name can't start with a hyphen. For more information, see Service Connect in the Amazon Elastic Container Service Developer Guide.