robbertkl / docker-ipv6nat

Extend Docker with IPv6 NAT, similar to IPv4
MIT License
661 stars 48 forks source link

Removal of ip6table Rules Upon Stopping Container #62

Closed abhinava closed 4 years ago

abhinava commented 4 years ago

Hi there! Thanks for this really awesome utility! I've been using this for few days now and seems to work really well!

One feature enhancement if you can consider, is to remove all the ip6table rules when the container is stopped. I tried to manually delete the rules myself externally after stopping the container but this seems a bit complex.

Perhaps you know the different chains and rules that are being created when the container is started - Perhaps you can have a script that can be run which can clean-up/remove these rules?

robbertkl commented 4 years ago

Hi @abhinava, docker-ipv6nat has a --cleanup flag for removing all of the created IPv6 rules on shutdown of docker-ipv6nat itself. Individual container rules are automatically added (and removed!) when containers get started/stopped (or connected/disconnected from a Docker network).

abhinava commented 4 years ago

Thanks! I'm using the container version (link) not the native binary as a Linux systemd service.

Is there a particular way to stop the container? If I try the "docker container stop..", the rules don't seem to be getting cleaned up. Perhaps Am I missing something?

robbertkl commented 4 years ago

You can add --retry --cleanup to the end of the command you use to start the ipv6nat container.

(--retry is the default, as can be seen in https://github.com/robbertkl/docker-ipv6nat/blob/master/Dockerfile)

abhinava commented 4 years ago

Awesome! Thanks for this tip!

Perhaps you could add this note to the README?

robbertkl commented 4 years ago

Great suggestion, I've clarified it a bit in the README, see e60fa0fbc096cd403d26ba2f0e29cc1bf13695a1.