Docker built-in network mappings

In previous chapters, we were mostly working with containers with the default network settings, which were utilizing the bridge network in most cases since that is the default, but this is not the only type of networking that can be used for a container. The following is a list of the available network connections, and almost all of them can be set through the docker run --network parameter:

  • bridge: As mentioned in earlier chapters, this type of network creates an independent virtual interface on the host for communicating with the container, and the container can communicate with the host and the Internet. Generally, inter-container communication is prevented in this type of a network.
  • none: Disables all networking communication for the container. This is useful with containers that only contain tooling and have no need for network communication.
  • host: Uses the host's networking stack and does not create any virtual interfaces.
  • <network_name_or_id>: Connects to a named network. This flag is useful when you create a network and want to put multiple containers in the same networking grouping. For example, this would be useful for hooking up multiple chatty containers such as Elasticsearch into their own isolated network.
  • <container_name_or_id>: This allows you to connect to a networking stack of the specified container. Just like the --pid flag, this is very useful for debugging running containers without directly attaching to them, though the network may need to be created with the --attachable flag depending on the network driver used.
Warning! Using the host networking switch gives the container full access to local system services and as such is a liability when used in any context other than testing. Use extreme caution when this flag is used, but luckily, there are only very few cases (if any) where there will be a legitimate use for this mode.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.28.93