[SOLVED] Unknown option "--dport" error installing 1st container: Portainer

Hi. Hope this is the right category
Issue type: Installation of first container
OS Version/build: Raspbian 10 Buster + Asterisk 16.6.1 & FreePBX 15.0.16.22
App version: docker-ce/buster,now 5:19.03.5~3-0~raspbian-buster armhf [installed]
iptables v1.8.2 (nf_tables)

In December last I installed Docker and Portainer without any problem. This was on a base image as above. I then lost my system and had to restart (my backup failed to reinstall).

This time after installing Portainer

docker run -d -p 9000:9000 -p 8000:8000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

I get the error:

docker: Error response from daemon: driver failed programming external connectivity on endpoint portainer (a714913cdd501bb1f601eaccf5ee1299eb0d1ef28e4fa6c1f8b4fae740a18b7b): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 9000 -j DNAT --to-destination 172.17.0.2:9000 ! -i docker0: iptables v1.8.2 (nf_tables): unknown option “–dport”
Try `iptables -h’ or ‘iptables --help’ for more information.
(exit status 2)).

A google search found others with a similar problem in early 2019, suggesting the problem was incompatibility with iptables v1.8.2 but that is at odds with the fact that the December installation was the same version for both Docker and iptables as I’m installing now.

I’m a newbie to Linux and Docker, so please try to keep your reply simple! Thank you.

PS I did try removingn and re-adding the container and also tried re-booting but the error persists.

[SOLVED}

I came across this post on github Cannot start container

Poster says “docker service starts right after network.target started, and doesn’t wait for network.target finished (including firewalld.service).”

As suggested I edited /lib/systemd/system/docker.service but slightly changed the suggested text to this:

Requires=network-online.target docker.socket

I then rebooted and could then get the log-in screen for Portainer.

Hopes this helps someone along the way.

Alan

1 Like

Thank you so much! This worked for me. How on earth did you figure this out? And could you please explain as to what was going on with the docker service boot? I have never encountered this error when I previously used portainer. Any idea as to why this popped up for me on the second clean installation?

Glad to hear it helped you. I’m sorry but this was 3 years ago, so I cannot remember.

Actually, I am switching my HA system from Domoticz to Home Assistant soon and will be doing a fresh install. I wonder if I will get the error again :wink:
Alan