본문 바로가기

Server Dev/Docker

[Docker] Container에서 외부로(External) 통신이 안될때

https://docs.docker.com/network/bridge/#enable-forwarding-from-docker-containers-to-the-outside-world

 

Use bridge networks

In terms of networking, a bridge network is a Link Layer device which forwards traffic between network segments. A bridge can be a hardware device or a software device running...

docs.docker.com

 

Enable forwarding from Docker containers to the outside world

By default, traffic from containers connected to the default bridge network is not forwarded to the outside world. To enable forwarding, you need to change two settings. These are not Docker commands and they affect the Docker host’s kernel.

  1. Configure the Linux kernel to allow IP forwarding.
  2. $ sysctl net.ipv4.conf.all.forwarding=1
  3. Change the policy for the iptables FORWARD policy from DROP to ACCEPT.
  4. $ sudo iptables -P FORWARD ACCEPT

These settings do not persist across a reboot, so you may need to add them to a start-up script.

 

P.S Official Document를 잘 찾아보자.