networkMode property
The Docker networking mode to use for the containers in the task. The valid
values are none
, bridge
, awsvpc
, and
host
. If no network mode is specified, the default is
bridge
.
For Amazon ECS tasks on Fargate, the awsvpc
network mode is
required. For Amazon ECS tasks on Amazon EC2 instances, any network mode can
be used. If the network mode is set to none
, you cannot specify
port mappings in your container definitions, and the tasks containers do not
have external connectivity. The host
and awsvpc
network modes offer the highest networking performance for containers
because they use the EC2 network stack instead of the virtualized network
stack provided by the bridge
mode.
With the host
and awsvpc
network modes, exposed
container ports are mapped directly to the corresponding host port (for the
host
network mode) or the attached elastic network interface
port (for the awsvpc
network mode), so you cannot take
advantage of dynamic host port mappings.
If the network mode is awsvpc
, the task is allocated an elastic
network interface, and you must specify a NetworkConfiguration value
when you create a service or run a task with the task definition. For more
information, see Task
Networking in the Amazon Elastic Container Service Developer
Guide.
If the network mode is host
, you cannot run multiple
instantiations of the same task on a single container instance when port
mappings are used.
Docker for Windows uses different network modes than Docker for Linux. When
you register a task definition with Windows containers, you must not specify
a network mode. If you use the console to register a task definition with
Windows containers, you must choose the <default>
network
mode object.
For more information, see Network settings in the Docker run reference.
Implementation
final NetworkMode? networkMode;