---
title: "Connect a container to a network"
method: POST
path: "/networks/{id}/connect"
tags: ["Network"]
---

# Connect a container to a network

`POST /networks/{id}/connect`

## Path parameters

- `id` string, required

## Request body

- object
  - `Container` string — The ID or name of the container to connect to the network.
  - `EndpointConfig` EndpointSettings — Configuration for a network endpoint.
    - `IPAMConfig` EndpointIPAMConfig, nullable — EndpointIPAMConfig represents an endpoint's IPAM configuration.
      - `IPv4Address` string
      - `IPv6Address` string
      - `LinkLocalIPs` string[]
    - `Links` string[]
    - `Aliases` string[]
    - `NetworkID` string — Unique ID of the network.
    - `EndpointID` string — Unique ID for the service endpoint in a Sandbox.
    - `Gateway` string — Gateway address for this network.
    - `IPAddress` string — IPv4 address.
    - `IPPrefixLen` integer — Mask length of the IPv4 address.
    - `IPv6Gateway` string — IPv6 gateway address.
    - `GlobalIPv6Address` string — Global IPv6 address.
    - `GlobalIPv6PrefixLen` integer — Mask length of the global IPv6 address.
    - `MacAddress` string — MAC address for the endpoint on this network.
    - `DriverOpts` object, nullable — DriverOpts is a mapping of driver options and values. These options are passed directly to the driver and are driver specific.

## Response `200`

No error

## Other responses

- `403` — Operation not supported for swarm scoped networks
- `404` — Network or container not found
- `500` — Server error

---

[API](https://skmtc.net/aliyun/apis/docker-engine-api.md) · [All operations](https://skmtc.net/aliyun/apis/docker-engine-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/aliyun/docker-engine-api/revisions/04bb09da9ccb/schema)
