問題文
Two containers on the same host must talk to each other by name, while neither should be reachable from outside the host. Which arrangement achieves both?
選択肢
- Run both containers with the host's network stack and rely on the firewall to block outside access, and sharing the host stack lets each container reach the other on the loopback address.
- Share a volume between the two containers so they can exchange data through files, and a shared file path serves as the address each container uses for the other.
- Publish each container's port to the host and add a rule that drops traffic from outside, since published ports are the only way containers can reach each other and name resolution between containers is provided by the host's resolver once the ports are published.
- Attach both containers to the same user-defined container network and publish no ports to the host.