---
title: "Discussion on \"The Docker port stays open with ufw\" | Hashnode"
description: "Discussion on \"The Docker port stays open with ufw\". A port published with docker run -p stays reachable from outside even with ufw active and a deny rule on that port. The test below ran on 18 November 2026 on Ubuntu 24.04.5 LTS, with Docker Engine 29."
url: "https://hashnode.com/posts/the-docker-port-stays-open-with-ufw/6afede04d43147adddaa7266"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [The Docker port stays open with ufw](https://nuvits.hashnode.dev/the-docker-port-stays-open-with-ufw?utm_source=hashnode&utm_medium=feed)

A port published with docker run -p stays reachable from outside even with ufw active and a deny rule on that port. The test below ran on 18 November 2026 on Ubuntu 24.04.5 LTS, with Docker Engine 29.

Nov 19 · 6 min read · nuvits.hashnode.dev  
Read the article

-   [#docker](https://hashnode.com/tag/docker)
-   [#security](https://hashnode.com/tag/security)
-   [#linux](https://hashnode.com/tag/linux)
-   [#devops](https://hashnode.com/tag/devops)
-   [#ufw](https://hashnode.com/tag/ufw)

## Written by

[Fernando Chagas](https://hashnode.com/@fernandochagas)

@fernandochagas

  
[View profile](https://hashnode.com/@fernandochagas)

Building Nuvits: VPS in Brazilian reais and MCP for AI agents

## Responses 4

Markdown supported · ⌘↵ to post

[c-wind](https://hashnode.com/@c-wind)

[Nov 19](https://hashnode.com/posts/the-docker-port-stays-open-with-ufw/6afede04d43147adddaa7266/comment/6afef3ca778dcdfa4abafafa)

Using a separate network namespace for the client is the important part here; a loopback check would miss the DNAT/FORWARD path entirely. The distinction between host port 8088 and the container’s port 80 in the `ufw route allow` example is also easy to miss. Did you repeat this with both Docker’s iptables-nft and legacy backends? That would help scope whether the behavior is tied to the backend, since the hook ordering can differ.

[Fernando Chagas](https://hashnode.com/@fernandochagas)

[5d ago](https://hashnode.com/posts/the-docker-port-stays-open-with-ufw/6afede04d43147adddaa7266/comment/6afef3ca778dcdfa4abafafa#reply-6b08a0217cc3ee7ce07a9067)

Only on Ubuntu 24.04's default (`iptables-nft`). I didn't re-run it on `iptables-legacy` or Docker's native nftables backend, so the results in the post are scoped to that default stack.

[OneLifeVibe](https://hashnode.com/@onelifevibe)

[Nov 19](https://hashnode.com/posts/the-docker-port-stays-open-with-ufw/6afede04d43147adddaa7266/comment/6afee9a7778dcdfa4abab3b7)

The test from a separate network namespace is the part that makes this convincing. A curl to 127.0.0.1 would have hidden the problem, and the point that the rule has to use the container port 80 rather than the host port 8088 is easy to get wrong. It is a useful reminder that a DENY IN rule in ufw status can look correct while the packet never passes through that chain.

[Fernando Chagas](https://hashnode.com/@fernandochagas)

[5d ago](https://hashnode.com/posts/the-docker-port-stays-open-with-ufw/6afede04d43147adddaa7266/comment/6afee9a7778dcdfa4abab3b7#reply-6b08a061c36097ef4cd538b5)

That `DENY IN` line is what trips most people up. Everything looks locked down in `ufw status` while traffic is still flowing through `FORWARD`, which is why testing from outside the host (or a separate namespace) is the only check that actually proves the port is closed.
