Junior — Middle
What is your experience with configuring and managing networks within Docker containers?
sobes.tech AI
Answer from AI
I have experience configuring networks within Docker containers, including creating custom networks for container isolation and interaction.
Docker supports several types of networks:
- bridge — the default network for containers on a single host.
- host — the container uses the host's network stack directly.
- overlay — for network communication between containers on different hosts (usually in Docker Swarm).
- macvlan — allows a container to have its own MAC address on the network.
Example of creating a custom network and running containers within it:
docker network create my_custom_network
docker run -d --name container1 --network my_custom_network my_image
docker run -d --name container2 --network my_custom_network my_image
This allows containers to communicate with each other by host names within the network. I also configured firewall rules and ports to ensure security and access.