github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/network_inspect.md (about)

     1  # network inspect
     2  
     3  <!---MARKER_GEN_START-->
     4  Display detailed information on one or more networks
     5  
     6  ### Options
     7  
     8  | Name                                      | Type     | Default | Description                                                                                                                                                                                                                                                        |
     9  |:------------------------------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
    10  | `-f`, `--format`                          | `string` |         | Format output using a custom template:<br>'json':             Print in JSON format<br>'TEMPLATE':         Print output using the given Go template.<br>Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates |
    11  | [`-v`](#verbose), [`--verbose`](#verbose) |          |         | Verbose output for diagnostics                                                                                                                                                                                                                                     |
    12  
    13  
    14  <!---MARKER_GEN_END-->
    15  
    16  ## Description
    17  
    18  Returns information about one or more networks. By default, this command renders
    19  all results in a JSON object.
    20  
    21  ## Examples
    22  
    23  ## Inspect the `bridge` network
    24  
    25  Connect two containers to the default `bridge` network:
    26  
    27  ```console
    28  $ sudo docker run -itd --name=container1 busybox
    29  f2870c98fd504370fb86e59f32cd0753b1ac9b69b7d80566ffc7192a82b3ed27
    30  
    31  $ sudo docker run -itd --name=container2 busybox
    32  bda12f8922785d1f160be70736f26c1e331ab8aaf8ed8d56728508f2e2fd4727
    33  ```
    34  
    35  The `network inspect` command shows the containers, by id, in its
    36  results. For networks backed by multi-host network driver, such as Overlay,
    37  this command also shows the container endpoints in other hosts in the
    38  cluster. These endpoints are represented as "ep-{endpoint-id}" in the output.
    39  However, for swarm mode networks, only the endpoints that are local to the
    40  node are shown.
    41  
    42  You can specify an alternate format to execute a given
    43  template for each result. Go's
    44  [text/template](https://pkg.go.dev/text/template) package describes all the
    45  details of the format.
    46  
    47  ```console
    48  $ sudo docker network inspect bridge
    49  ```
    50  
    51  The output is in JSON format, for example:
    52  
    53  ```json
    54  [
    55    {
    56      "Name": "bridge",
    57      "Id": "b2b1a2cba717161d984383fd68218cf70bbbd17d328496885f7c921333228b0f",
    58      "Created": "2016-10-19T04:33:30.360899459Z",
    59      "Scope": "local",
    60      "Driver": "bridge",
    61      "IPAM": {
    62        "Driver": "default",
    63        "Config": [
    64          {
    65            "Subnet": "172.17.42.1/16",
    66            "Gateway": "172.17.42.1"
    67          }
    68        ]
    69      },
    70      "Internal": false,
    71      "Containers": {
    72        "bda12f8922785d1f160be70736f26c1e331ab8aaf8ed8d56728508f2e2fd4727": {
    73          "Name": "container2",
    74          "EndpointID": "0aebb8fcd2b282abe1365979536f21ee4ceaf3ed56177c628eae9f706e00e019",
    75          "MacAddress": "02:42:ac:11:00:02",
    76          "IPv4Address": "172.17.0.2/16",
    77          "IPv6Address": ""
    78        },
    79        "f2870c98fd504370fb86e59f32cd0753b1ac9b69b7d80566ffc7192a82b3ed27": {
    80          "Name": "container1",
    81          "EndpointID": "a00676d9c91a96bbe5bcfb34f705387a33d7cc365bac1a29e4e9728df92d10ad",
    82          "MacAddress": "02:42:ac:11:00:01",
    83          "IPv4Address": "172.17.0.1/16",
    84          "IPv6Address": ""
    85        }
    86      },
    87      "Options": {
    88        "com.docker.network.bridge.default_bridge": "true",
    89        "com.docker.network.bridge.enable_icc": "true",
    90        "com.docker.network.bridge.enable_ip_masquerade": "true",
    91        "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
    92        "com.docker.network.bridge.name": "docker0",
    93        "com.docker.network.driver.mtu": "1500"
    94      },
    95      "Labels": {}
    96    }
    97  ]
    98  ```
    99  
   100  ### Inspect a user-defined network
   101  
   102  Create and inspect a user-defined network:
   103  
   104  ```console
   105  $ docker network create simple-network
   106  
   107  69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a
   108  ```
   109  
   110  ```console
   111  $ docker network inspect simple-network
   112  ```
   113  
   114  The output is in JSON format, for example:
   115  
   116  ```json
   117  [
   118    {
   119      "Name": "simple-network",
   120      "Id": "69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a",
   121      "Created": "2016-10-19T04:33:30.360899459Z",
   122      "Scope": "local",
   123      "Driver": "bridge",
   124      "IPAM": {
   125        "Driver": "default",
   126        "Config": [
   127          {
   128            "Subnet": "172.22.0.0/16",
   129            "Gateway": "172.22.0.1"
   130          }
   131        ]
   132      },
   133      "Containers": {},
   134      "Options": {},
   135      "Labels": {}
   136    }
   137  ]
   138  ```
   139  
   140  ### Inspect the `ingress` network
   141  
   142  For swarm mode overlay networks `network inspect` also shows the IP address and node name
   143  of the peers. Peers are the nodes in the swarm cluster which have at least one task attached
   144  to the network. Node name is of the format `<hostname>-<unique ID>`.
   145  
   146  ```console
   147  $ docker network inspect ingress
   148  ```
   149  
   150  The output is in JSON format, for example:
   151  
   152  ```json
   153  [
   154    {
   155      "Name": "ingress",
   156      "Id": "j0izitrut30h975vk4m1u5kk3",
   157      "Created": "2016-11-08T06:49:59.803387552Z",
   158      "Scope": "swarm",
   159      "Driver": "overlay",
   160      "EnableIPv6": false,
   161      "IPAM": {
   162        "Driver": "default",
   163        "Options": null,
   164        "Config": [
   165          {
   166            "Subnet": "10.255.0.0/16",
   167            "Gateway": "10.255.0.1"
   168          }
   169        ]
   170      },
   171      "Internal": false,
   172      "Attachable": false,
   173      "Containers": {
   174        "ingress-sbox": {
   175          "Name": "ingress-endpoint",
   176          "EndpointID": "40e002d27b7e5d75f60bc72199d8cae3344e1896abec5eddae9743755fe09115",
   177          "MacAddress": "02:42:0a:ff:00:03",
   178          "IPv4Address": "10.255.0.3/16",
   179          "IPv6Address": ""
   180        }
   181      },
   182      "Options": {
   183        "com.docker.network.driver.overlay.vxlanid_list": "256"
   184      },
   185      "Labels": {},
   186      "Peers": [
   187        {
   188          "Name": "net-1-1d22adfe4d5c",
   189          "IP": "192.168.33.11"
   190        },
   191        {
   192          "Name": "net-2-d55d838b34af",
   193          "IP": "192.168.33.12"
   194        },
   195        {
   196          "Name": "net-3-8473f8140bd9",
   197          "IP": "192.168.33.13"
   198        }
   199      ]
   200    }
   201  ]
   202  ```
   203  
   204  ### <a name="verbose"></a> View detailed information of a network (--verbose)
   205  
   206  `docker network inspect --verbose` for swarm mode overlay networks shows service-specific
   207  details such as the service's VIP and port mappings. It also shows IPs of service tasks,
   208  and the IPs of the nodes where the tasks are running.
   209  
   210  Following is an example output for an overlay network `ov1` that has one service `s1`
   211  attached to. service `s1` in this case has three replicas.
   212  
   213  ```console
   214  $ docker network inspect --verbose ov1
   215  ```
   216  
   217  The output is in JSON format, for example:
   218  
   219  ```json
   220  [
   221    {
   222      "Name": "ov1",
   223      "Id": "ybmyjvao9vtzy3oorxbssj13b",
   224      "Created": "2017-03-13T17:04:39.776106792Z",
   225      "Scope": "swarm",
   226      "Driver": "overlay",
   227      "EnableIPv6": false,
   228      "IPAM": {
   229        "Driver": "default",
   230        "Options": null,
   231        "Config": [
   232          {
   233            "Subnet": "10.0.0.0/24",
   234            "Gateway": "10.0.0.1"
   235          }
   236        ]
   237      },
   238      "Internal": false,
   239      "Attachable": false,
   240      "Containers": {
   241        "020403bd88a15f60747fd25d1ad5fa1272eb740e8a97fc547d8ad07b2f721c5e": {
   242          "Name": "s1.1.pjn2ik0sfgkfzed3h0s00gs9o",
   243          "EndpointID": "ad16946f416562d658f3bb30b9830d73ad91ccf6feae44411269cd0ff674714e",
   244          "MacAddress": "02:42:0a:00:00:04",
   245          "IPv4Address": "10.0.0.4/24",
   246          "IPv6Address": ""
   247        }
   248      },
   249      "Options": {
   250        "com.docker.network.driver.overlay.vxlanid_list": "4097"
   251      },
   252      "Labels": {},
   253      "Peers": [
   254        {
   255          "Name": "net-3-5d3cfd30a58c",
   256          "IP": "192.168.33.13"
   257        },
   258        {
   259          "Name": "net-1-6ecbc0040a73",
   260          "IP": "192.168.33.11"
   261        },
   262        {
   263          "Name": "net-2-fb80208efd75",
   264          "IP": "192.168.33.12"
   265        }
   266      ],
   267      "Services": {
   268        "s1": {
   269          "VIP": "10.0.0.2",
   270          "Ports": [],
   271          "LocalLBIndex": 257,
   272          "Tasks": [
   273            {
   274              "Name": "s1.2.q4hcq2aiiml25ubtrtg4q1txt",
   275              "EndpointID": "040879b027e55fb658e8b60ae3b87c6cdac7d291e86a190a3b5ac6567b26511a",
   276              "EndpointIP": "10.0.0.5",
   277              "Info": {
   278                "Host IP": "192.168.33.11"
   279              }
   280            },
   281            {
   282              "Name": "s1.3.yawl4cgkp7imkfx469kn9j6lm",
   283              "EndpointID": "106edff9f120efe44068b834e1cddb5b39dd4a3af70211378b2f7a9e562bbad8",
   284              "EndpointIP": "10.0.0.3",
   285              "Info": {
   286                "Host IP": "192.168.33.12"
   287              }
   288            },
   289            {
   290              "Name": "s1.1.pjn2ik0sfgkfzed3h0s00gs9o",
   291              "EndpointID": "ad16946f416562d658f3bb30b9830d73ad91ccf6feae44411269cd0ff674714e",
   292              "EndpointIP": "10.0.0.4",
   293              "Info": {
   294                "Host IP": "192.168.33.13"
   295              }
   296            }
   297          ]
   298        }
   299      }
   300    }
   301  ]
   302  ```
   303  
   304  ## Related commands
   305  
   306  * [network disconnect ](network_disconnect.md)
   307  * [network connect](network_connect.md)
   308  * [network create](network_create.md)
   309  * [network ls](network_ls.md)
   310  * [network rm](network_rm.md)
   311  * [network prune](network_prune.md)
   312  * [Understand Docker container networks](https://docs.docker.com/engine/userguide/networking/)