for-linux icon indicating copy to clipboard operation
for-linux copied to clipboard

Docker Network problem FILTER chain Iptables

Open Hugo1380 opened this issue 6 years ago • 15 comments

  • [x] This is a bug report
  • [ ] This is a feature request
  • [x] I searched existing issues before opening this one

Expected behavior

Create a docker network or use a docker-compose including a network creation.

Actual behavior

Error response from daemon: Failed to program FILTER chain: iptables failed: iptables --wait -I FORWARD -o br-ad0b6136ca3d -j DOCKER: iptables v1.8.2 (nf_tables):  RULE_INSERT failed (Invalid argument): rule in chain FORWARD
 (exit status 4)

Steps to reproduce the behavior

docker network create test

Output of docker version:

Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea838
 Built:             Wed Nov 13 07:25:38 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea838
  Built:            Wed Nov 13 07:24:09 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker info:

Client:
 Debug Mode: false

Server:
 Containers: 13
  Running: 6
  Paused: 0
  Stopped: 7
 Images: 41
 Server Version: 19.03.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.4.182-mainline-rev1
 Operating System: Debian GNU/Linux 10 (buster)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.62GiB
 Name: DEDIHUGO
 ID: OCER:S7KK:KZVH:WFZT:MSUH:Q5YE:N6GH:UNTQ:CAZ3:73ID:VCC6:K2HO
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.) Already done : Reinstall docker

Hugo1380 avatar Feb 12 '20 15:02 Hugo1380

Same problem in Debian 10 with : docker client version: 18.09.01 docker server engine: 18.09.01 API version: 1.39

FabC avatar Mar 15 '20 11:03 FabC

I had the same issue. I could solve this by restarting the whole docker service again, and wait some moments, as during start, the docker service recreates the iptable targets. Maybe you also have to remove the docker iptable beforehand to enforce the recreation of the docker target

auxua avatar Mar 30 '20 14:03 auxua

Same problem here with Debian 10 and docker 19.03.8. Restarting docker service did not solve the problem.

...but running apt update && apt dist-upgrade and restarting the server SOLVED the problem.

thorstenhirsch avatar Apr 14 '20 20:04 thorstenhirsch

I have the same problem in Debian 10. My Docker version info:

Client: Docker Engine - Community
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46
 Built:             Wed Sep 16 17:06:25 2020
 OS/Arch:           linux/arm
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       4484c46
  Built:            Wed Sep 16 17:00:11 2020
  OS/Arch:          linux/arm
  Experimental:     false
 containerd:
  Version:          1.3.9

I tried to solve like @thorstenhirsch, but it my case this did not the solve the problem. Any other hints what I could try?

CountCypher avatar Dec 01 '20 20:12 CountCypher

Same problem

debian 10.5
Docker version 18.06.3-ce, build d7080c1
docker-compose version 1.24.1, build 4667896b
$ docker-compose up
Creating network "myapp-container_default" with the default driver
ERROR: Failed to program FILTER chain: iptables failed: iptables --wait -I FORWARD -o br-99bba58ff8cc -j DOCKER: iptables v1.8.2 (nf_tables):  RULE_INSERT failed (Invalid argument): rule in chain FORWARD
 (exit status 4)

davewood avatar Dec 05 '20 08:12 davewood

Resolved by restarting service. thanks to auxua $ sudo systemctl restart docker

bajtekv avatar Dec 07 '20 23:12 bajtekv

Debian 10 here, using auto-upgrades.

I also resolved by restarting service. thanks to @auxua $ sudo systemctl restart docker

LunkRat avatar Dec 22 '20 20:12 LunkRat

I had the docker network problem on Debian 10 for arm, so in my case the root cause is related to this issue. Hence restarting docker service alone didn't do the trick. I had to switch to iptables-legacy as well:

$ sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
$ sudo systemctl restart docker

...and it needed a system reboot afterwards. But with that the problem was solved for me.

CountCypher avatar Dec 28 '20 15:12 CountCypher

Hi,

I have the same issue:

  • Debian 10.10 on VirtualBox
  • Docker version 20.10.8, build 3967b7d
  • iptables v1.8.2 (nf_tables)

Restarting docker service or the system does not resolve the issue.

I have investigated iptables behavior for my case:

  • running iptables with the failing command shown in the output fails with the same error
    # iptables --wait -I FORWARD -o br-dce828037f78 -j DOCKER
    iptables v1.8.2 (nf_tables):  RULE_INSERT failed (Invalid argument): rule in chain FORWARD
    
  • running the command and changing the target to another chain succeeds
    # iptables --wait -I FORWARD -o br-dce828037f78 -j RETURN
    
  • stopping docker service, then running the failing command succeeds
    # service docker stop
    # iptables --wait -I FORWARD -o br-dce828037f78 -j DOCKER
    

This last operation is not a workaround, as the docker network create command has failed and the interface has not been created.
Moreover, iptables rules created before the failure have not been purged, so manually cleaning iptables is required. Below are the iptables rules that need to be removed

# iptables-save
*nat
-A POSTROUTING -s 172.18.0.0/16 ! -o br-dce828037f78 -j MASQUERADE
-A DOCKER -i br-dce828037f78 -j RETURN
*filter
-A FORWARD -i br-dce828037f78 ! -o br-dce828037f78 -j ACCEPT
-A FORWARD -i br-dce828037f78 -o br-dce828037f78 -j ACCEPT

EDIT: nftables is enabled on the system, I currently don't know it there can be a link with the iptables error

bbonnefon avatar Aug 30 '21 14:08 bbonnefon

I had the same problem with Debian 10 on x64 and after updating from Docker 19.03.12 to 20.10.8

When re-deploying a stack the network didn't work. After switching to iptables-legacy everything seems to work fine.

mr-simonski avatar Sep 03 '21 09:09 mr-simonski

Thanks Indeed, I could switch to iptables-legacy with update-alternatives. Now "docker network create" works

bbonnefon avatar Sep 03 '21 12:09 bbonnefon

I had the same problem with Ubuntu 20.04 on x64 and after apt upgrade.

I also resolved by restarting service. thanks to @thorstenhirsch.

$ sudo systemctl restart docker

tuxxon avatar Jan 09 '22 06:01 tuxxon

Resolved by restarting service. thanks to auxua $ sudo systemctl restart docker

Before I try this I use this command

apt update && apt dist-upgrade

Then I use your command.

sudo systemctl restart docker

Thank you, brother. This worked for me.

taraqr9 avatar Jan 11 '22 03:01 taraqr9

Any news if this is actually a docker issue or a buggy Debian/Ubuntu upgrade? Will it be fixed in the future?

gueldenstone avatar Jan 31 '22 08:01 gueldenstone

Any news if this is actually a docker issue or a buggy Debian/Ubuntu upgrade? Will it be fixed in the future?

I faced this error after upgrade packages in Ubuntu 18.0.4: Failed to program FILTER chain: iptables failed: iptables --wait -I FORWARD -o br-4e7af96b92f1 -j DOCKER: iptables v1.6.1: Couldn't load targetDOCKER':No such file or directory`

hamed-mahdizadeh avatar Jan 31 '22 19:01 hamed-mahdizadeh