{"id":53815,"date":"2025-09-14T17:31:43","date_gmt":"2025-09-14T07:31:43","guid":{"rendered":"https:\/\/www.cloudproinc.com.au\/?p=53815"},"modified":"2025-09-14T17:31:46","modified_gmt":"2025-09-14T07:31:46","slug":"publish-a-port-from-a-container-to-your-computer","status":"publish","type":"post","link":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/","title":{"rendered":"Publish a Port from a Container to Your Computer"},"content":{"rendered":"\n<p>In this blog post Publish a Port from a Container to Your Computer the Right Way we will walk through what port publishing really means, why it matters, and how to do it correctly across Docker, Podman, and Kubernetes.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Publishing a port connects an application running in an isolated container to the outside world. With the right mapping, your team can browse a web app on localhost, expose APIs to other hosts, or route traffic through a load balancer. Done poorly, you can create security holes, debugging headaches, or performance bottlenecks. In Publish a Port from a Container to Your Computer the Right Way we start high level, then move into commands, configuration, and practical guardrails.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-it-means-to-publish-a-port\">What it means to publish a port<\/h2>\n\n\n\n<p>Containers run with their own network stack. By default, they are invisible to your computer\u2019s network. Publishing a port creates a path from a host interface and port (for example, 127.0.0.1:8080) to a port inside the container (for example, 80). Your browser or client connects to the host; Docker or Podman forwards the traffic to the container.<\/p>\n\n\n\n<p>Important distinction: EXPOSE in a Dockerfile documents intent; it does not publish anything. The -p\/&#8211;publish flag (or ports in Compose) actually binds the port on your computer and forwards traffic.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-happens-under-the-hood\">What happens under the hood<\/h2>\n\n\n\n<p>On Linux, <a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/category\/docker\/\">Docker <\/a>and Podman connect containers to a virtual bridge (often docker0 or cni-podman0). Each container gets a virtual Ethernet pair (veth). Traffic from the host to the container crosses this bridge. Port publishing configures NAT and firewall rules (iptables or nftables) and may use a lightweight proxy so that connections to the host port are forwarded to the container\u2019s IP and port.<\/p>\n\n\n\n<p>On macOS and Windows, Docker Desktop runs containers inside a lightweight VM (HyperKit\/Apple Virtualization on macOS, WSL2 or Hyper-V on Windows). When you publish a port, Docker sets up forwarding from the host OS into that VM and then into the container. It feels like localhost, but it hops through a VM.<\/p>\n\n\n\n<p>Because of this architecture, performance is usually good, but certain edge cases (firewalls, VPNs, corporate proxies, or overlapping subnets) can interfere. Knowing the path helps you troubleshoot.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-quick-start-publish-a-port-with-docker\">Quick start publish a port with Docker<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Run a sample web server:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code has-black-background-color has-background\"><code>docker run -d --name web -p 8080:80 nginx:stable-alpine\n<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Test it from your computer:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-72dc68e5f2e0108917f595f848a77066\"><code>curl -I http:\/\/localhost:8080\/\n# or open http:\/\/localhost:8080 in your browser<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Bind to a specific interface (recommended on shared hosts):<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-8f2937364a42b98a49b4675956a44730\"><code>docker run -d --name web --restart unless-stopped \\\n  -p 127.0.0.1:8080:80 nginx:stable-alpine\n# Only reachable from the local machine<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-best-practice-port-mappings\">Best-practice port mappings<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Map a host port to a container port: <code>-p HOST:CONTAINER<\/code> (for TCP by default).<\/li>\n\n\n\n<li>Limit exposure by binding to localhost: <code>-p 127.0.0.1:8080:80<\/code>.<\/li>\n\n\n\n<li>Bind to a specific address if you must expose: <code>-p 192.168.1.50:8080:80<\/code>.<\/li>\n\n\n\n<li>Publish UDP when needed: <code>-p 514:514\/udp<\/code>.<\/li>\n\n\n\n<li>Let Docker choose a free host port: <code>-p 0:80<\/code> (check the assigned port with <code>docker ps<\/code> or <code>docker inspect<\/code>).<\/li>\n\n\n\n<li>Publish all documented ports from the image: <code>-P<\/code> (uppercase). Use with caution; it may expose more than you intend.<\/li>\n<\/ul>\n\n\n\n<p>Inside the container, ensure the app listens on 0.0.0.0 (all interfaces), not just 127.0.0.1. If it binds only to localhost inside the container, publishing will not work.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-docker-compose-example\">Docker Compose example<\/h2>\n\n\n\n<p>Compose makes port publishing reproducible and version-controlled.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-b2ca1a0a1388a6f74993f6cc774ce6b7\"><code>version: \"3.9\"\nservices:\n  web:\n    image: nginx:stable-alpine\n    ports:\n      - \"8080:80\"           # exposed publicly on the host\n      - \"127.0.0.1:5432:5432\"  # example of localhost-only port (e.g., a DB)\n    restart: unless-stopped\n<\/code><\/pre>\n\n\n\n<p>Bring it up and test:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-9f20a68fd39d0082ea509539c9812ba4\"><code>docker compose up -d\ncurl -I http:\/\/localhost:8080\/\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-podman-notes\">Podman notes<\/h2>\n\n\n\n<p>Podman uses the same <code>-p<\/code> syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-8d19fb630f4d223303accbddd9817e45\"><code>podman run -d --name web -p 8080:80 nginx:stable-alpine\n<\/code><\/pre>\n\n\n\n<p>Rootless Podman can\u2019t bind to privileged ports (&lt;1024) by default. Either map to a higher host port (for example, 8080) or adjust the system setting (<code>net.ipv4.ip_unprivileged_port_start<\/code>) if policy allows.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-kubernetes-equivalents\">Kubernetes equivalents<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-local-debugging-with-port-forward\">Local debugging with port-forward<\/h3>\n\n\n\n<p>When you only need quick access from your machine to a Pod or Service:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-8190f541ee412aef985bd647d4e1d060\"><code>kubectl port-forward svc\/my-service 8080:80\n# Then browse http:\/\/localhost:8080<\/code><\/pre>\n\n\n\n<p><code>port-forward<\/code> is ephemeral and does not expose anything to the cluster\u2019s external network.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-publish-a-service-on-node-ports\">Publish a Service on node ports<\/h3>\n\n\n\n<p>To make a Service reachable from outside the cluster without a cloud load balancer:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-19bcfe9496212b6584c70590795c9d70\"><code>apiVersion: v1\nkind: Service\nmetadata:\n  name: web\nspec:\n  type: NodePort\n  selector:\n    app: web\n  ports:\n    - port: 80\n      targetPort: 8080\n      nodePort: 30080\n<\/code><\/pre>\n\n\n\n<p>Clients reach any node at <code>http:\/\/NODE_IP:30080<\/code>. In managed clouds, prefer <code>LoadBalancer<\/code> Services or an Ingress controller for cleaner URLs and TLS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-security-essentials\">Security essentials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Find the conflicting process: <code>sudo lsof -iTCP:8080 -sTCP:LISTEN<\/code> or <code>ss -ltnp | grep :8080<\/code>.<\/li>\n\n\n\n<li>Stop or reconfigure the other service, or map a different host port.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-symptom-works-on-linux-but-not-on-macos-windows\">Symptom: works on Linux but not on macOS\/Windows<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Remember Docker Desktop uses a VM. Security tools or corporate VPNs may not route to the VM. Try a different port, disable the security tool temporarily, or configure the VPN to allow local networking.<\/li>\n\n\n\n<li>For WSL2 on Windows, confirm you are using the correct localhost. Newer Docker Desktop versions forward automatically; older setups required extra port proxy rules.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-verify-end-to-end\">Verify end to end<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>From host: <code>curl -v http:\/\/127.0.0.1:8080<\/code><\/li>\n\n\n\n<li>From inside container: <code>curl -v http:\/\/127.0.0.1:80<\/code> and <code>curl -v http:\/\/&lt;container-ip>:80<\/code><\/li>\n\n\n\n<li>Inspect bindings: <code>docker inspect &lt;ctr> | jq '.[0].NetworkSettings.Ports'<\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-common-patterns-and-anti-patterns\">Common patterns and anti-patterns<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Pattern: Local-only dev services. Map to 127.0.0.1 so teammates can run safely on laptops.<\/li>\n\n\n\n<li>Pattern: Reverse proxy at the edge. Publish only ports 80\/443 on NGINX\/Traefik and route internally to app containers on private networks.<\/li>\n\n\n\n<li>Pattern: Random host ports in CI. Use <code>-p 0:&lt;port><\/code> and emit the chosen port in logs for parallel test jobs.<\/li>\n\n\n\n<li>Anti-pattern: Publishing databases directly to the internet. Use private networking, VPC peering, or SSH tunnels instead.<\/li>\n\n\n\n<li>Anti-pattern: Relying solely on EXPOSE. It does nothing without -p or Compose ports.<\/li>\n\n\n\n<li>Anti-pattern: Using host network casually. <code>--network host<\/code> removes isolation and increases port conflicts; reserve it for specific performance cases.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-advanced-tips\">Advanced tips<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>IPv6: Bind explicitly if needed, for example <code>-p [::1]:8080:80<\/code> for localhost IPv6.<\/li>\n\n\n\n<li>Multiple ports: <code>-p 8080:80 -p 8443:443<\/code>.<\/li>\n\n\n\n<li>Health checks: Combine published ports with <code>HEALTHCHECK<\/code> and container orchestrator probes to detect failures.<\/li>\n\n\n\n<li>Observability: Expose Prometheus metrics on a separate local-only port and scrape from the host.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-summary\">Summary<\/h2>\n\n\n\n<p>Publishing a port bridges your container\u2019s private world to your computer or network. On Linux it\u2019s a bridge and NAT; on macOS\/Windows it\u2019s forwarded through a VM. The essentials are simple: map the right ports, bind to the right interface, limit exposure, and verify with basic network tools. With the steps and checks above, you can publish ports confidently for development, demos, and production\u2014without surprises.<\/p>\n\n\n\n<ul class=\"wp-block-yoast-seo-related-links yoast-seo-related-links\">\n<li><a href=\"https:\/\/cloudproinc.azurewebsites.net\/index.php\/2025\/08\/25\/run-neo4j-with-docker-inside-github-codespaces\/\">Run Neo4j with Docker inside GitHub Codespaces<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/05\/13\/publish-a-blazor-net-app-with-vs-code-to-azure\/\">Publish a Blazor .NET App With VS Code to Azure<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2024\/10\/15\/set-timezone-on-computers-with-microsoft-intune-and-graph-api\/\">Set TimeZone on Computers with Microsoft Intune and Graph API<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2025\/09\/10\/how-to-share-volumes-between-docker-containers\/\">How to Share Volumes Between Docker Containers<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/cloudproinc.azurewebsites.net\/index.php\/2025\/09\/01\/publish-winui-app-to-windows-11-machines\/\">Publish WinUI App to Windows 11 Machines<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to publish container ports safely and reliably, with clear steps for Docker, Podman, and Kubernetes, plus troubleshooting and security best practices.<\/p>\n","protected":false},"author":1,"featured_media":53816,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_focuskw":"Publish a Port from a Container to Your Computer","_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"Learn how to publish a port from a container to your computer effectively and avoid common mistakes in Docker and Kubernetes.","_yoast_wpseo_opengraph-title":"","_yoast_wpseo_opengraph-description":"","_yoast_wpseo_twitter-title":"","_yoast_wpseo_twitter-description":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13,70],"tags":[],"class_list":["post-53815","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-docker"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Publish a Port from a Container to Your Computer - CPI Consulting<\/title>\n<meta name=\"description\" content=\"Learn how to publish a port from a container to your computer effectively and avoid common mistakes in Docker and Kubernetes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Publish a Port from a Container to Your Computer\" \/>\n<meta property=\"og:description\" content=\"Learn how to publish a port from a container to your computer effectively and avoid common mistakes in Docker and Kubernetes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/\" \/>\n<meta property=\"og:site_name\" content=\"CPI Consulting\" \/>\n<meta property=\"article:published_time\" content=\"2025-09-14T07:31:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-14T07:31:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudproinc.com.au\/wp-content\/uploads\/2025\/09\/publish-a-port-from-a-container-to-your-computer-the-right-way.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1536\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CPI Staff\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CPI Staff\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/\"},\"author\":{\"name\":\"CPI Staff\",\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/#\\\/schema\\\/person\\\/192eeeb0ce91062126ce3822ae88fe6e\"},\"headline\":\"Publish a Port from a Container to Your Computer\",\"datePublished\":\"2025-09-14T07:31:43+00:00\",\"dateModified\":\"2025-09-14T07:31:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/\"},\"wordCount\":960,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/#primaryimage\"},\"thumbnailUrl\":\"\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/publish-a-port-from-a-container-to-your-computer-the-right-way.png\",\"articleSection\":[\"Blog\",\"Docker\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/\",\"url\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/\",\"name\":\"Publish a Port from a Container to Your Computer - CPI Consulting\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/#primaryimage\"},\"thumbnailUrl\":\"\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/publish-a-port-from-a-container-to-your-computer-the-right-way.png\",\"datePublished\":\"2025-09-14T07:31:43+00:00\",\"dateModified\":\"2025-09-14T07:31:46+00:00\",\"description\":\"Learn how to publish a port from a container to your computer effectively and avoid common mistakes in Docker and Kubernetes.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/#primaryimage\",\"url\":\"\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/publish-a-port-from-a-container-to-your-computer-the-right-way.png\",\"contentUrl\":\"\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/publish-a-port-from-a-container-to-your-computer-the-right-way.png\",\"width\":1536,\"height\":1024,\"caption\":\"publish-a-port-from-a-container-to-your-computer-the-right-way\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/2025\\\/09\\\/14\\\/publish-a-port-from-a-container-to-your-computer\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.cloudproinc.com.au\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Publish a Port from a Container to Your Computer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/#website\",\"url\":\"https:\\\/\\\/cloudproinc.com.au\\\/\",\"name\":\"Cloud Pro Inc - CPI Consulting Pty Ltd\",\"description\":\"Cloud, AI &amp; Cybersecurity Consulting | Melbourne\",\"publisher\":{\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/cloudproinc.com.au\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/#organization\",\"name\":\"Cloud Pro Inc - Cloud Pro Inc - CPI Consulting Pty Ltd\",\"url\":\"https:\\\/\\\/cloudproinc.com.au\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/favfinalfile.png\",\"contentUrl\":\"\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/favfinalfile.png\",\"width\":500,\"height\":500,\"caption\":\"Cloud Pro Inc - Cloud Pro Inc - CPI Consulting Pty Ltd\"},\"image\":{\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cloudproinc.com.au\\\/#\\\/schema\\\/person\\\/192eeeb0ce91062126ce3822ae88fe6e\",\"name\":\"CPI Staff\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g\",\"caption\":\"CPI Staff\"},\"sameAs\":[\"http:\\\/\\\/www.cloudproinc.com.au\"],\"url\":\"https:\\\/\\\/cloudproinc.com.au\\\/index.php\\\/author\\\/cpiadmin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Publish a Port from a Container to Your Computer - CPI Consulting","description":"Learn how to publish a port from a container to your computer effectively and avoid common mistakes in Docker and Kubernetes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/","og_locale":"en_US","og_type":"article","og_title":"Publish a Port from a Container to Your Computer","og_description":"Learn how to publish a port from a container to your computer effectively and avoid common mistakes in Docker and Kubernetes.","og_url":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/","og_site_name":"CPI Consulting","article_published_time":"2025-09-14T07:31:43+00:00","article_modified_time":"2025-09-14T07:31:46+00:00","og_image":[{"width":1536,"height":1024,"url":"https:\/\/cloudproinc.com.au\/wp-content\/uploads\/2025\/09\/publish-a-port-from-a-container-to-your-computer-the-right-way.png","type":"image\/png"}],"author":"CPI Staff","twitter_card":"summary_large_image","twitter_misc":{"Written by":"CPI Staff","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/#article","isPartOf":{"@id":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/"},"author":{"name":"CPI Staff","@id":"https:\/\/cloudproinc.com.au\/#\/schema\/person\/192eeeb0ce91062126ce3822ae88fe6e"},"headline":"Publish a Port from a Container to Your Computer","datePublished":"2025-09-14T07:31:43+00:00","dateModified":"2025-09-14T07:31:46+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/"},"wordCount":960,"commentCount":0,"publisher":{"@id":"https:\/\/cloudproinc.com.au\/#organization"},"image":{"@id":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2025\/09\/publish-a-port-from-a-container-to-your-computer-the-right-way.png","articleSection":["Blog","Docker"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/","url":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/","name":"Publish a Port from a Container to Your Computer - CPI Consulting","isPartOf":{"@id":"https:\/\/cloudproinc.com.au\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/#primaryimage"},"image":{"@id":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2025\/09\/publish-a-port-from-a-container-to-your-computer-the-right-way.png","datePublished":"2025-09-14T07:31:43+00:00","dateModified":"2025-09-14T07:31:46+00:00","description":"Learn how to publish a port from a container to your computer effectively and avoid common mistakes in Docker and Kubernetes.","breadcrumb":{"@id":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/#primaryimage","url":"\/wp-content\/uploads\/2025\/09\/publish-a-port-from-a-container-to-your-computer-the-right-way.png","contentUrl":"\/wp-content\/uploads\/2025\/09\/publish-a-port-from-a-container-to-your-computer-the-right-way.png","width":1536,"height":1024,"caption":"publish-a-port-from-a-container-to-your-computer-the-right-way"},{"@type":"BreadcrumbList","@id":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/14\/publish-a-port-from-a-container-to-your-computer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cloudproinc.com.au\/"},{"@type":"ListItem","position":2,"name":"Publish a Port from a Container to Your Computer"}]},{"@type":"WebSite","@id":"https:\/\/cloudproinc.com.au\/#website","url":"https:\/\/cloudproinc.com.au\/","name":"Cloud Pro Inc - CPI Consulting Pty Ltd","description":"Cloud, AI &amp; Cybersecurity Consulting | Melbourne","publisher":{"@id":"https:\/\/cloudproinc.com.au\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudproinc.com.au\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudproinc.com.au\/#organization","name":"Cloud Pro Inc - Cloud Pro Inc - CPI Consulting Pty Ltd","url":"https:\/\/cloudproinc.com.au\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudproinc.com.au\/#\/schema\/logo\/image\/","url":"\/wp-content\/uploads\/2022\/01\/favfinalfile.png","contentUrl":"\/wp-content\/uploads\/2022\/01\/favfinalfile.png","width":500,"height":500,"caption":"Cloud Pro Inc - Cloud Pro Inc - CPI Consulting Pty Ltd"},"image":{"@id":"https:\/\/cloudproinc.com.au\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/cloudproinc.com.au\/#\/schema\/person\/192eeeb0ce91062126ce3822ae88fe6e","name":"CPI Staff","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2d96eeb53b791d92c8c50dd667e3beec92c93253bb6ff21c02cfa8ca73665c70?s=96&d=mm&r=g","caption":"CPI Staff"},"sameAs":["http:\/\/www.cloudproinc.com.au"],"url":"https:\/\/cloudproinc.com.au\/index.php\/author\/cpiadmin\/"}]}},"jetpack_featured_media_url":"\/wp-content\/uploads\/2025\/09\/publish-a-port-from-a-container-to-your-computer-the-right-way.png","jetpack-related-posts":[{"id":53790,"url":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/08\/keep-net-app-running-in-docker\/","url_meta":{"origin":53815,"position":0},"title":"Keep .NET App Running in Docker","author":"CPI Staff","date":"September 8, 2025","format":false,"excerpt":"Learn how to containerise a .NET app, start it automatically, and keep it running with Docker and Docker Compose\u2014production-friendly, developer-happy.","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/cloudproinc.com.au\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/09\/keep-your-net-app-running-in-docker-the-right-way-with-compose.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/09\/keep-your-net-app-running-in-docker-the-right-way-with-compose.png 1x, \/wp-content\/uploads\/2025\/09\/keep-your-net-app-running-in-docker-the-right-way-with-compose.png 1.5x, \/wp-content\/uploads\/2025\/09\/keep-your-net-app-running-in-docker-the-right-way-with-compose.png 2x, \/wp-content\/uploads\/2025\/09\/keep-your-net-app-running-in-docker-the-right-way-with-compose.png 3x, \/wp-content\/uploads\/2025\/09\/keep-your-net-app-running-in-docker-the-right-way-with-compose.png 4x"},"classes":[]},{"id":53420,"url":"https:\/\/cloudproinc.com.au\/index.php\/2025\/06\/25\/containerize-a-blazor-net-application\/","url_meta":{"origin":53815,"position":1},"title":"Containerize a Blazor .NET Application","author":"CPI Staff","date":"June 25, 2025","format":false,"excerpt":"In this blog post, we will show you how to containerize a Blazor .NET application using native tools\u2014without relying on third-party scripts or complex setups. Microsoft .NET is one of the most popular development frameworks today, offering a wide range of deployment options. Running applications in containers and adopting microservices\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/cloudproinc.com.au\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/02\/How-to-Add-Bootstrap-to-a-.NET-Blazor-9-Web-Application.webp","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/02\/How-to-Add-Bootstrap-to-a-.NET-Blazor-9-Web-Application.webp 1x, \/wp-content\/uploads\/2025\/02\/How-to-Add-Bootstrap-to-a-.NET-Blazor-9-Web-Application.webp 1.5x, \/wp-content\/uploads\/2025\/02\/How-to-Add-Bootstrap-to-a-.NET-Blazor-9-Web-Application.webp 2x, \/wp-content\/uploads\/2025\/02\/How-to-Add-Bootstrap-to-a-.NET-Blazor-9-Web-Application.webp 3x, \/wp-content\/uploads\/2025\/02\/How-to-Add-Bootstrap-to-a-.NET-Blazor-9-Web-Application.webp 4x"},"classes":[]},{"id":53820,"url":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/15\/host-and-run-a-website-inside-docker-for-fast-portable-deploys\/","url_meta":{"origin":53815,"position":2},"title":"Host and Run a Website inside Docker for Fast, Portable Deploys","author":"CPI Staff","date":"September 15, 2025","format":false,"excerpt":"Learn how to containerise, serve, and secure a website with Docker. From first run to production-ready patterns, this guide covers images, volumes, networks, and TLS.","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/cloudproinc.com.au\/index.php\/category\/blog\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/09\/host-and-run-a-website-inside-docker-for-fast-portable-deploys.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/09\/host-and-run-a-website-inside-docker-for-fast-portable-deploys.png 1x, \/wp-content\/uploads\/2025\/09\/host-and-run-a-website-inside-docker-for-fast-portable-deploys.png 1.5x, \/wp-content\/uploads\/2025\/09\/host-and-run-a-website-inside-docker-for-fast-portable-deploys.png 2x, \/wp-content\/uploads\/2025\/09\/host-and-run-a-website-inside-docker-for-fast-portable-deploys.png 3x, \/wp-content\/uploads\/2025\/09\/host-and-run-a-website-inside-docker-for-fast-portable-deploys.png 4x"},"classes":[]},{"id":53823,"url":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/15\/connecting-to-a-running-container-terminal\/","url_meta":{"origin":53815,"position":3},"title":"Connecting to a Running Container Terminal","author":"CPI Staff","date":"September 15, 2025","format":false,"excerpt":"Learn practical ways to attach a shell to running containers in Docker and Kubernetes, when to use them, and how to stay safe in production.","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/cloudproinc.com.au\/index.php\/category\/blog\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/09\/connecting-to-a-running-container-terminal-in-docker-and-kubernetes.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/09\/connecting-to-a-running-container-terminal-in-docker-and-kubernetes.png 1x, \/wp-content\/uploads\/2025\/09\/connecting-to-a-running-container-terminal-in-docker-and-kubernetes.png 1.5x, \/wp-content\/uploads\/2025\/09\/connecting-to-a-running-container-terminal-in-docker-and-kubernetes.png 2x, \/wp-content\/uploads\/2025\/09\/connecting-to-a-running-container-terminal-in-docker-and-kubernetes.png 3x, \/wp-content\/uploads\/2025\/09\/connecting-to-a-running-container-terminal-in-docker-and-kubernetes.png 4x"},"classes":[]},{"id":53841,"url":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/15\/create-a-blank-neo4j-instance\/","url_meta":{"origin":53815,"position":4},"title":"Create a Blank Neo4j Instance","author":"CPI Staff","date":"September 15, 2025","format":false,"excerpt":"Spin up a clean Neo4j graph quickly and securely. We cover Docker, a Linux VM, and Kubernetes, plus practical security, persistence, and backup tips.","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/cloudproinc.com.au\/index.php\/category\/blog\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/09\/create-a-blank-neo4j-instance-safely-on-docker-vm-or-kubernetes.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/09\/create-a-blank-neo4j-instance-safely-on-docker-vm-or-kubernetes.png 1x, \/wp-content\/uploads\/2025\/09\/create-a-blank-neo4j-instance-safely-on-docker-vm-or-kubernetes.png 1.5x, \/wp-content\/uploads\/2025\/09\/create-a-blank-neo4j-instance-safely-on-docker-vm-or-kubernetes.png 2x, \/wp-content\/uploads\/2025\/09\/create-a-blank-neo4j-instance-safely-on-docker-vm-or-kubernetes.png 3x, \/wp-content\/uploads\/2025\/09\/create-a-blank-neo4j-instance-safely-on-docker-vm-or-kubernetes.png 4x"},"classes":[]},{"id":53933,"url":"https:\/\/cloudproinc.com.au\/index.php\/2025\/09\/25\/deploy-a-model-with-tensorflow-serving\/","url_meta":{"origin":53815,"position":5},"title":"Deploy a Model with TensorFlow Serving","author":"CPI Staff","date":"September 25, 2025","format":false,"excerpt":"Learn to package, serve, and scale TensorFlow models using Docker and Kubernetes with TensorFlow Serving. Practical steps, code, and production tips for teams.","rel":"","context":"In &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/cloudproinc.com.au\/index.php\/category\/ai\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/09\/deploy-a-model-with-tensorflow-serving-on-docker-and-kubernetes.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/09\/deploy-a-model-with-tensorflow-serving-on-docker-and-kubernetes.png 1x, \/wp-content\/uploads\/2025\/09\/deploy-a-model-with-tensorflow-serving-on-docker-and-kubernetes.png 1.5x, \/wp-content\/uploads\/2025\/09\/deploy-a-model-with-tensorflow-serving-on-docker-and-kubernetes.png 2x, \/wp-content\/uploads\/2025\/09\/deploy-a-model-with-tensorflow-serving-on-docker-and-kubernetes.png 3x, \/wp-content\/uploads\/2025\/09\/deploy-a-model-with-tensorflow-serving-on-docker-and-kubernetes.png 4x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/53815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=53815"}],"version-history":[{"count":2,"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/53815\/revisions"}],"predecessor-version":[{"id":53818,"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/53815\/revisions\/53818"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/media\/53816"}],"wp:attachment":[{"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=53815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/categories?post=53815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/tags?post=53815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}