-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firewall Rules for Process Isolated Containers Don't Work as Expected #561
Comments
Thank you for creating an Issue. Please note that GitHub is not an official channel for Microsoft support requests. To create an official support request, please open a ticket here. Microsoft and the GitHub Community strive to provide a best effort in answering questions and supporting Issues on GitHub. |
Hi @sikhness, when running containers on an l2bridge network, external traffic to the container first reaches the vSwitch. Here, VFP rewrites the port from the host to the container port. The packet is then forwarded to the container's vNIC, where the firewall rule is processed. Therefore, you need to specify the container port rather than the host port when setting firewall rules. More info on l2bridge container networking here. |
Hi @adrianm-msft, How would you go about solving the issue where you want to control the firewall rules for multiple containers running that share the same port within their respective containers but are mapped to different host ports? Is that not possible without having to change the container port itself and then perform firewall rules on that? I'm using NAT networking (the default), is that also the same as l2bridge in terms of firewall rules? |
You can try setting ACLs on the container's vNIC. For example, to block inbound traffic to port 80 on a container with IP address "172.30.81.218", from the container host using the HNS module in PowerShell:
This should allow you to specify ACL rules for multiple containers that may expose the same port. |
Describe the bug
When building an image in docker with exposed ports, and you run a process isolated container from that image with that exposed port mapped to something else, defining a Windows Firewall rule does not work on the mapped port, instead you have to define it on the port you exposed in the image which is odd.
For example, if you define
EXPOSE 9443
in a Dockerfile during the build of an image, and then run a container using this image and map the port to something else like-p 9081:9443
, you would expect that your firewall rules would need to be defined on port 9081 since that is the one exposed to the host. However, you instead need to define it on 9443 for it to take effect.This is an issue because if you use the same image or other images with the same internal ports, despite you mapping them to different individual host ports when running containers made from them, all containers using that image will have the firewall rule applied to it regardless of which port you have it mapped to.
To Reproduce
EXPOSE 9443
-p 9081:9443
Expected behavior
The expected behaviour should be that creating a block all firewall rule on the mapped port (9081 in this example) would block the service on 9081, but instead it does nothing.
Configuration:
The text was updated successfully, but these errors were encountered: