public ContainerDefinition withPortMappings(PortMapping... portMappings) {
        if (this.portMappings == null) {
            setPortMappings(new com.amazonaws.internal.SdkInternalList<PortMapping>(portMappings.length));
        }
        for (PortMapping ele : portMappings) {
            this.portMappings.add(ele);
        }
        return this;
    }
<p>
The list of port mappings for the container. Port mappings allow containers to access ports on the host container
instance to send or receive traffic.
</p>
<p>
For task definitions that use the <code>awsvpc</code> network mode, only specify the <code>containerPort</code>.
The <code>hostPort</code> can be left blank or it must be the same value as the <code>containerPort</code>.
</p>
<p>
Port mappings on Windows use the <code>NetNAT</code> gateway address rather than <code>localhost</code>. There's
no loopback for port mappings on Windows, so you can't access a container's mapped port from the host itself.
</p>
<p>
This parameter maps to <code>PortBindings</code> in the <a
href="https://docs.docker.com/engine/api/v1.35/#operation/ContainerCreate">Create a container</a> section of the
<a href="https://docs.docker.com/engine/api/v1.35/">Docker Remote API</a> and the <code>--publish</code> option
to <a href="https://docs.docker.com/engine/reference/run/#security-configuration">docker run</a>. If the network
mode of a task definition is set to <code>none</code>, then you can't specify port mappings. If the network mode
of a task definition is set to <code>host</code>, then host ports must either be undefined or they must match the
container port in the port mapping.
</p>
<note>
<p>
After a task reaches the <code>RUNNING</code> status, manual and automatic host and container port assignments
are visible in the <b>Network Bindings</b> section of a container description for a selected task in the Amazon
ECS console. The assignments are also visible in the <code>networkBindings</code> section <a>DescribeTasks</a>
responses.
</p>
</note>
<p>
<b>NOTE:</b> This method appends the values to the existing list (if any). Use
{@link #setPortMappings(java.util.Collection)} or {@link #withPortMappings(java.util.Collection)} if you want to
override the existing values.
</p>

@param portMappings
       The list of port mappings for the container. Port mappings allow containers to access ports on the host
       container instance to send or receive traffic.</p>
       <p>
       For task definitions that use the <code>awsvpc</code> network mode, only specify the
       <code>containerPort</code>. The <code>hostPort</code> can be left blank or it must be the same value as
       the <code>containerPort</code>.
       </p>
       <p>
       Port mappings on Windows use the <code>NetNAT</code> gateway address rather than <code>localhost</code>.
       There's no loopback for port mappings on Windows, so you can't access a container's mapped port from the
       host itself.
       </p>
       <p>
       This parameter maps to <code>PortBindings</code> in the <a
       href="https://docs.docker.com/engine/api/v1.35/#operation/ContainerCreate">Create a container</a> section
       of the <a href="https://docs.docker.com/engine/api/v1.35/">Docker Remote API</a> and the
       <code>--publish</code> option to <a
       href="https://docs.docker.com/engine/reference/run/#security-configuration">docker run</a>. If the network
       mode of a task definition is set to <code>none</code>, then you can't specify port mappings. If the
       network mode of a task definition is set to <code>host</code>, then host ports must either be undefined or
       they must match the container port in the port mapping.
       </p>
       <note>
       <p>
       After a task reaches the <code>RUNNING</code> status, manual and automatic host and container port
       assignments are visible in the <b>Network Bindings</b> section of a container description for a selected
       task in the Amazon ECS console. The assignments are also visible in the <code>networkBindings</code>
       section <a>DescribeTasks</a> responses.
       </p>
@return Returns a reference to this object so that method calls can be chained together.
aws-java-sdk-ecs/src/main/java/com/amazonaws/services/ecs/model/ContainerDefinition.java