Linux 6.18.x 버전에서 docker가 구동 안될 때

오늘 Gentoo Linux의 커널을 업데이트 후 docker가 구동 안되는 문제가 발생했다. 메시지는 아래와같이 발생.

Mar 20 18:46:44 tun.iruis.net dockerd[11723]: failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to register "bridge" driver: failed to create NAT chain DOCKER: iptables failed: iptables --wait -t nat -N DOCKER: modprobe: FATAL: Module ip_tables not found in directory /lib/modules/6.18.18-gentoo
Mar 20 18:46:44 tun.iruis.net dockerd[11723]: iptables v1.8.11 (legacy): can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Mar 20 18:46:44 tun.iruis.net dockerd[11723]: Perhaps iptables or your kernel needs to be upgraded.
Mar 20 18:46:44 tun.iruis.net dockerd[11723]:  (exit status 3)
Mar 20 18:46:44 tun.iruis.net dockerd[11723]: time="2026-03-20T18:46:44.297442507+09:00" level=info msg="stopping event stream following graceful shutdown" error="context canceled" module=libcontainerd namespace=plugins.moby

뜬금없이 ip_tables 모듈을 사용할 수 없다는 메시지가 떠서 커널 소스를 확인해보니 net/netfilter/Makefile 파일에 아래와같은 코드가 있다.

obj-$(CONFIG_IP_NF_IPTABLES_LEGACY) += ip_tables.o

즉, 기존의 ip_tables가 legacy로 분류된 것. 해당 항목을 선택하기 위해서는 아래 항목을 선택하면 된다.

-> Networking support
  -> Networking options
    -> Network packet filtering framework (Netfilter)
      -> Core Netfilter Configuration
        -> Netfilter Xtables support (required for ip_tables)
          -> [*] Netfilter legacy tables support
      -> IP: Netfilter Configuration
        -> <M> Legacy IP tables support

NETFILTER_XTABLES_LEGACY를 먼저 선택 후 표시되는 Legacy IP tables support가 선택되었는지 확인하여 자동으로 선택 안되었다면 모듈을 선택하면 된다.

 # make -j12
  SYNC    include/config/auto.conf
  DESCEND objtool
  CALL    scripts/checksyscalls.sh
  INSTALL libsubcmd_headers
  CC [M]  net/ipv4/netfilter/ip_tables.o
  CC [M]  net/ipv4/netfilter/iptable_filter.o
  CC [M]  net/ipv4/netfilter/iptable_mangle.o
  CC [M]  net/ipv6/netfilter/ip6_tables.o
  UPD     kernel/config_data
  GZIP    kernel/config_data.gz
  CC [M]  net/ipv6/netfilter/ip6table_filter.o
  CC [M]  kernel/configs.o
  CC [M]  net/ipv6/netfilter/ip6table_mangle.o
  CC [M]  net/netfilter/x_tables.o
  MODPOST Module.symvers
Kernel: arch/x86/boot/bzImage is ready  (#2)
  LD [M]  kernel/configs.ko
  CC [M]  net/netfilter/x_tables.mod.o
  CC [M]  net/ipv4/netfilter/ip_tables.mod.o
  CC [M]  net/ipv4/netfilter/iptable_mangle.mod.o
  CC [M]  net/ipv4/netfilter/iptable_filter.mod.o
  CC [M]  net/ipv6/netfilter/ip6_tables.mod.o
  CC [M]  net/ipv6/netfilter/ip6table_filter.mod.o
  CC [M]  net/ipv6/netfilter/ip6table_mangle.mod.o
  LD [M]  net/netfilter/x_tables.ko
  LD [M]  net/ipv4/netfilter/ip_tables.ko
  LD [M]  net/ipv6/netfilter/ip6table_filter.ko
  LD [M]  net/ipv6/netfilter/ip6_tables.ko
  LD [M]  net/ipv6/netfilter/ip6table_mangle.ko
  LD [M]  net/ipv4/netfilter/iptable_mangle.ko
  LD [M]  net/ipv4/netfilter/iptable_filter.ko

위와같이 추가로 선택 된 모듈이 빌드되었다. 이것을 설치하고 재부팅하니 docker 실행 해결. 만약 nat 모듈 오류도 발생한다면 ip_tables 모듈이 legacy가 되어 해제된것이니 아래 항목을 더 선택하여 빌드하면된다.

-> Networking support
  -> Networking options
    -> Network packet filtering framework (Netfilter)
      -> IP: Netfilter Configuration
        -> IP tables support (required for filtering/masq/NAT)
          -> iptables NAT support

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

*
*