I am trying to set specific iptables rules inside a container but so far i have no luck. So far i tried to enter (exec bash) the container and add manually the rules, then, export the running container to a new image.
When i import the image and start the new container the iptable rules are still not there.
How can i have specific iptables rules when the container is created without having to set them automatically?
I am using docker-CE 19.03.1
The image is a custom debian-strech created using debootstrap.
Best Answer
I managed to implement this by:
1) adding all iptables rules i wish to apply on a bash script .
2) Copy the bash to the container using the Dockerfile
3) Use again Dockerfile to run the iptables bash script within the container.
For example:
iptables script
Dockerfile