What is the purpose of the --network parameter in docker run?

0126

The --network parameter in the docker run command is used to specify the network to which the container should be connected. Here are the key purposes:

  1. Container Communication: It allows containers to communicate with each other over a specified network. Containers on the same network can use their names as hostnames to connect.

  2. Isolation: By connecting containers to different networks, you can isolate them from each other, enhancing security and organization.

  3. Custom Networks: You can connect containers to custom bridge networks, enabling more complex networking setups, such as service discovery and load balancing.

For example, using --network my-custom-network connects the container to a network named my-custom-network.

If you have further questions or need examples, feel free to ask!

0 Comments

no data
Be the first to share your comment!