{"id":4635,"date":"2025-06-04T07:52:40","date_gmt":"2025-06-04T07:52:40","guid":{"rendered":"https:\/\/iprovpn.com\/blog\/?p=4635"},"modified":"2025-08-27T10:37:09","modified_gmt":"2025-08-27T10:37:09","slug":"docker-port-forwarding","status":"publish","type":"post","link":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/","title":{"rendered":"Docker Port Forwarding &#8211; A Network Mapping Overview"},"content":{"rendered":"<p>Have you ever wondered how to connect your applications in a Docker environment without compromising their external accessibility?<\/p>\n<p>Docker port forwarding emerges as a critical networking and accessibility jigsaw piece in the ever-evolving world of <a href=\"https:\/\/middleware.io\/blog\/containerization\/\">containerization<\/a> and DevOps.<\/p>\n<p>In this article, we&#8217;ll break down Docker port forwarding, explain its significance, and discuss how it facilitates communication between your containers and the more extensive network. Learn everything there is to know about Docker run port forwarding &#8211; it&#8217;s easier than you might think.<\/p>\n        <div class=\"iprovpn_btn_cta_row\">\n    \t<a class=\"btn_cta\" href=\"https:\/\/iprovpn.com\/buy-vpn\" title=\"Get iProVPN Now\">Get iProVPN NOW <i class=\"fas fa-long-arrow-alt-right\"><\/i><\/a>\n    \t<\/div>\n    \n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_75 ez-toc-wrap-center counter-flat ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<div class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/div>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #000000;color:#000000\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #000000;color:#000000\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Short_on_Time_Weve_Got_Your_Back\" >Short on Time? We\u2019ve Got Your Back<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#What_We_Will_Be_Covering\" >What We Will Be Covering<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#What_is_Docker_Port_Forwarding\" >What is Docker Port Forwarding?<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Is_Docker_Port_Forwarding_Not_Working_Bypass_the_CGNAT_Challenge\" >Is Docker Port Forwarding Not Working? Bypass the CGNAT Challenge<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Setting_up_iProVPN_for_Port_Forwarding_in_Docker\" >Setting up iProVPN for Port Forwarding in Docker<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_1_Register_and_Install_iProVPN\" >Step 1: Register and Install iProVPN<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_2_Connect_to_a_Port_Forwarding-Compatible_Server\" >Step 2: Connect to a Port Forwarding-Compatible Server<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_3_Enable_Port_Forwarding\" >Step 3: Enable Port Forwarding<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_4_Specify_Port_Number_and_Device_IP\" >Step 4: Specify Port Number and Device IP<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_5_Save_Changes\" >Step 5: Save Changes<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#How_to_Do_Port_Forwarding_in_a_Docker_Container\" >How to Do Port Forwarding in a Docker Container?<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_1_Identify_the_Container_Port\" >Step 1: Identify the Container Port<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_2_Choose_a_Host_Port\" >Step 2: Choose a Host Port<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_3_Map_the_Ports\" >Step 3: Map the Ports<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_4_Test_the_Connection\" >Step 4: Test the Connection<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_5_Persist_the_Port_Mapping\" >Step 5: Persist the Port Mapping<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Step_6_Use_Docker_Compose\" >Step 6: Use Docker Compose<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#What_Is_the_Difference_Between_Docker_Expose_and_Port_Forward\" >What Is the Difference Between Docker Expose and Port Forward?<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Wrapping_Up\" >Wrapping Up<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#FAQs_%E2%80%93_Docker_Port_Forwarding\" >FAQs &#8211; Docker Port Forwarding<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#How_to_allow_a_Docker_container_to_make_HTTP_requests_using_port_forwarding\" >How to allow a Docker container to make HTTP requests using port forwarding?<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#What_ports_does_Docker_use\" >What ports does Docker use?<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#How_to_bind_a_port_to_Docker_container\" >How to bind a port to Docker container?<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#Start_Browsing_Privately\" >Start Browsing Privately!<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Short_on_Time_Weve_Got_Your_Back\"><\/span>Short on Time? We\u2019ve Got Your Back<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Docker port forwarding enables communication within Docker containers while limiting external access.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">For incoming and outgoing communication, Docker employs port mapping to connect host ports to container ports.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">CGNAT can restrict internet access; iProVPN offers impressive <a href=\"https:\/\/iprovpn.com\/features\" target=\"_blank\" rel=\"noopener\">features<\/a> to circumvent CGNAT and allow port forwarding.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Configure iProVPN to use a specific server and port for Docker port forwarding.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Docker port forwarding entails locating, selecting, mapping, testing, and maintaining ports.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">In Docker Compose, the &#8220;expose&#8221; and &#8220;ports&#8221; keys configure port accessibility; &#8220;ports&#8221; is visible on both the host and the network, while &#8220;expose&#8221; is only visible on the network.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"What_We_Will_Be_Covering\"><\/span>What We Will Be Covering<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\">What is Docker Port Forwarding?<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Is Docker Port Forwarding Not Working? Bypass the CGNAT Challenge<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Setting up iProVPN for Port Forwarding in Docker<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">How to Do Port Forwarding in a Docker Container?<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">What Is the Difference Between Docker Expose and Port Forward?<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"What_is_Docker_Port_Forwarding\"><\/span>What is Docker Port Forwarding?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In Docker, port mapping, or port forwarding, involves connecting a port on the host system to a port on a Docker container, using the host system&#8217;s network interface, allowing incoming and outgoing network traffic from the container.<\/p>\n<p>Docker containers function in isolated environments with their customized network stacks, including unique <a href=\"https:\/\/iprovpn.com\/blog\/what-is-an-ip-address\/\" target=\"_blank\" rel=\"noopener\">IP addresses<\/a> and network ports, when running. By default, containers are segregated from the more extensive external network but can communicate with the host system and each other. Port mapping enables access from the external network or other hosts linked to the host system&#8217;s network by making specific container ports visible to the host system.<\/p>\n<p>Port mapping is typically used to make containerized apps or services reachable from outside the container. This indicates that they may be contacted by standard network protocols such as HTTP, HTTPS, SSH, and others. In essence, it provides a way to expose container ports and enable access from either the host system or the outside network while <a href=\"https:\/\/www.wiz.io\/academy\/what-is-container-security\" target=\"_blank\" rel=\"noopener\">maintaining the network isolation of the container<\/a>.<\/p>\n<p>Docker utilizes the -p or &#8211;publish option to achieve port mapping when launching containers. Here\u2019s the syntax for standard port forwarding:<\/p>\n<p>Docker run -p [host_port]:[container_port] my_container<\/p>\n<p>To port mapping on the 8080 and the container 80, use the following syntax:<\/p>\n<p>Docker run -p 8080:80 my_container<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Is_Docker_Port_Forwarding_Not_Working_Bypass_the_CGNAT_Challenge\"><\/span>Is Docker Port Forwarding Not Working? Bypass the CGNAT Challenge<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>CGNAT Carrier-Grade Network Address Translation (CGNAT) can impose restrictions on internet usage, even though it can effectively mitigate IPv4 address depletion. However, gaining access to ports that CGNAT hides is a significant problem for many users.<\/p>\n<p>CGNAT is a technique that internet service providers use to preserve IP addresses. Reaching devices or services positioned behind CGNAT becomes challenging since it restricts inbound connections.<\/p>\n<p>But fret not! You can now easily bypass CGNAT issues with iProVPN. It offers a dependable and secure way to unlock ports within the constraints of CGNAT. With the help of this solution, it is simple to access numerous devices and services remotely.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Setting_up_iProVPN_for_Port_Forwarding_in_Docker\"><\/span>Setting up iProVPN for Port Forwarding in Docker<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>iProVPN is an effective technique for circumventing CGNAT restrictions. It connects the user&#8217;s device to a <a href=\"https:\/\/iprovpn.com\/servers\">VPN server<\/a> and assigns it a unique public IP address. This allows users to circumvent CGNAT limitations and successfully proceed with Docker run port forwarding.<\/p>\n<p>Here\u2019s a step-by-step guide for port forwarding in Docker through a VPN:<\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Register and install <a href=\"https:\/\/iprovpn.com\/\">iProVPN<\/a>.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Connect to a Port Forwarding-Compatible Server.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Enable Port Forwarding.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Specify the Port Number and Device IP.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Save Changes.<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Step_1_Register_and_Install_iProVPN\"><\/span>Step 1: Register and Install iProVPN<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To begin, purchase and <a href=\"https:\/\/iprovpn.com\/download\">install iProVPN<\/a> on your device.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_2_Connect_to_a_Port_Forwarding-Compatible_Server\"><\/span>Step 2: Connect to a Port Forwarding-Compatible Server<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Launch iProVPN and connect to a server that supports port forwarding.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Form a server connection through the iProVPN app.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Step_3_Enable_Port_Forwarding\"><\/span>Step 3: Enable Port Forwarding<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Navigate to the &#8220;Port Forwarding&#8221; tab or area in the iProVPN application.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_4_Specify_Port_Number_and_Device_IP\"><\/span>Step 4: Specify Port Number and Device IP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Enter the port number you want to forward in the &#8220;Port Forwarding&#8221; box. Provide the device&#8217;s IP address to which you wish to forward the port. Ascertain that the device is linked to the same network as your VPN.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_5_Save_Changes\"><\/span>Step 5: Save Changes<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>After entering the device&#8217;s port number and IP address, click the &#8220;Apply&#8221; or &#8220;Save&#8221; button to save the changes.<\/p>\n<p>That&#8217;s all! You have successfully configured Docker run port forwarding in iProVPN, allowing you to send specific network traffic to the forwarded port.<\/p>\n        <div class=\"iprovpn_btn_cta_row\">\n    \t<a class=\"btn_cta\" href=\"https:\/\/iprovpn.com\/buy-vpn\" title=\"Get iProVPN Now\">Get iProVPN NOW <i class=\"fas fa-long-arrow-alt-right\"><\/i><\/a>\n    \t<\/div>\n    \n<h2><span class=\"ez-toc-section\" id=\"How_to_Do_Port_Forwarding_in_a_Docker_Container\"><\/span>How to Do Port Forwarding in a Docker Container?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Here\u2019s a step-by-step guide for port forwarding in Docker:<\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Identify the Container Port.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Choose a Host Port.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Map the Ports.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Test the Connection.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Persist the Port Mapping.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Use Docker Compose.<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Step_1_Identify_the_Container_Port\"><\/span>Step 1: Identify the Container Port<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Begin by deciding which port of your Docker container you want to open. This can be accomplished by checking the container with the following command:<\/p>\n<p>Docker inspect &lt;container_name_or_id&gt;<\/p>\n<p>This command returns a JSON representation of your container. To find the container port, go to the &#8220;ExposedPorts&#8221; section.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_2_Choose_a_Host_Port\"><\/span>Step 2: Choose a Host Port<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>After identifying the container port, you must choose a host port to which it will be mapped. The host port is where your Docker host will receive container traffic. On your Docker host, you can use any accessible port. Let&#8217;s use port 8080 for this example.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_3_Map_the_Ports\"><\/span>Step 3: Map the Ports<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Use the &#8220;Docker run&#8221; command with the following syntax to map the container port to the host port:<\/p>\n<p>Docker run -p &lt;host_port&gt;:&lt;container_port&gt; &lt;image_name&gt;<\/p>\n<p>Use the &#8220;nginx&#8221; image to map host port 8080 to container port 80:<\/p>\n<p>Docker run -p 8080:80 nginx<\/p>\n<p>This command starts a new container with the &#8220;nginx&#8221; image and connects host port 8080 to container port 80.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_4_Test_the_Connection\"><\/span>Step 4: Test the Connection<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>After mapping the ports, open a web browser and navigate to your Docker host&#8217;s IP address, followed by port 8080, to see if the connection works. You should see the Nginx welcome page if everything is set up successfully.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_5_Persist_the_Port_Mapping\"><\/span>Step 5: Persist the Port Mapping<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Docker containers are ephemeral by default, which implies that modifications made to them are not stored once they are stopped or removed. When running the &#8220;Docker run&#8221; command, use the &#8220;-P&#8221; flag instead of the &#8220;-p&#8221; flag to maintain the port mapping.<\/p>\n<p>All exposed ports are mapped to random host ports using the &#8220;-P&#8221; flag:<\/p>\n<p>Docker run -P nginx<\/p>\n<p>Use the \u201cDocker port\u201d command to view the port mapping:<\/p>\n<p>Docker port &lt;container_name_or_id&gt;<\/p>\n<p>This command will display the host port mapping for all exposed container ports.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_6_Use_Docker_Compose\"><\/span>Step 6: Use Docker Compose<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Docker Compose is a sophisticated tool for managing Docker applications that run in many containers. It lets you declare port mappings in a YAML file for simple maintenance and deployment.<\/p>\n<p>This is how you configure port forwarding in a Docker Compose file (host port 8080) :<\/p>\n<p>Services:<\/p>\n<p>Web:<\/p>\n<p>image: nginx<\/p>\n<p>Ports:<\/p>\n<p>&#8211; &#8220;8080:80&#8221;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"What_Is_the_Difference_Between_Docker_Expose_and_Port_Forward\"><\/span>What Is the Difference Between Docker Expose and Port Forward?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The &#8220;expose&#8221; and &#8220;ports&#8221; keys in Docker Compose configure network settings and define which ports a container should expose. Their accessibility, however, differs.<\/p>\n<p>The fundamental distinction is how &#8220;expose&#8221; and &#8220;ports&#8221; work. The &#8220;expose&#8221; key makes container ports visible to other services on the same network. Still, not to the host system directly. Conversely, &#8221; Ports expose and publish ports on the host system and make them available to associated networks.<\/p>\n<p>The fundamental distinction between these two keys is that &#8220;ports&#8221; are exposed and available on both the host system and the specified network. Whereas &#8220;expose&#8221; is only exposed on the selected network and can only be accessed by services running on that network.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Wrapping_Up\"><\/span>Wrapping Up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Docker run port forwarding is essential in Docker since it lets you expose container ports to another environment, allowing you to run apps in an isolated environment while keeping them accessible. By following the methods in this guide, you can easily configure port forwarding in Docker and enjoy its benefits for optimizing performance.<br \/>\n\n<div class=\"blog_faq\">\n                <h3 class=\"main_title\">FAQs - Docker Port Forwarding<\/h3> \n                        <div class=\"faq\">\n            <h3 class=\"faq_title\"><span class=\"ez-toc-section\" id=\"How_to_allow_a_Docker_container_to_make_HTTP_requests_using_port_forwarding\"><\/span>How to allow a Docker container to make HTTP requests using port forwarding? <i class=\"fa fa-plus\"><\/i><span class=\"ez-toc-section-end\"><\/span><\/h3> \n                        <div class=\"faq_description\">\n                <p>You don't need port forwarding to allow a Docker container to send HTTP queries. Outbound network access is enabled by default for containers. Run the container and make HTTP queries with tools like curl.<\/p>\n            <\/div>\n            <\/div>\n                \n                <div class=\"faq\">\n            <h3 class=\"faq_title\"><span class=\"ez-toc-section\" id=\"What_ports_does_Docker_use\"><\/span>What ports does Docker use? <i class=\"fa fa-plus\"><\/i><span class=\"ez-toc-section-end\"><\/span><\/h3> \n                        <div class=\"faq_description\">\n                <p>Docker makes use of multiple default ports for a variety of purposes:\r\n<ul>\r\n<li>Container Ports<\/li>\r\n<li>Docker Daemon Communication<\/li>\r\n<li>2Docker Swarm Communication<\/li>\r\n<ul><\/p>\n            <\/div>\n            <\/div>\n                \n                <div class=\"faq\">\n            <h3 class=\"faq_title\"><span class=\"ez-toc-section\" id=\"How_to_bind_a_port_to_Docker_container\"><\/span>How to bind a port to Docker container? <i class=\"fa fa-plus\"><\/i><span class=\"ez-toc-section-end\"><\/span><\/h3> \n                        <div class=\"faq_description\">\n                <p>To bind a port to a Docker container, use the -p or --publish flag when running the container:\r\nphp\r\nCopy code\r\nDocker run -p : \r\nThis maps the host machine's specified port to the container's port, enabling communication.<\/p>\n            <\/div>\n            <\/div>\n                \n        \n    \n    \n    \n    \n    \n    \n    \n    <\/div>\n\n<\/p>\n    \t<hr class=\"mt-5\">\n        <div class=\"custom_CTA mt-5\">\n            <div class=\"row\">\n                <div class=\"col-lg-7 align-self-center text-lg-left text-center\">\n                    <h3><span class=\"ez-toc-section\" id=\"Start_Browsing_Privately\"><\/span>Start Browsing Privately!<span class=\"ez-toc-section-end\"><\/span><\/h3>\n                    <p clas=\"mb-0\">iProVPN encrypts your data for protection against hackers and surveillance. Unblock your favorite streaming platforms instantly with the best VPN for streaming.<\/p>\n                <\/div>\n                <div class=\"col-lg-5 align-self-center text-center\">\n                    <a class=\"custom_btn_cta\" href=\"https:\/\/iprovpn.com\/buy-vpn\" title=\"Get iProVPN Now\">Get iProVPN NOW<\/a>\n                <\/div>\n            <\/div>\n    \t<\/div>\n    \n","protected":false},"excerpt":{"rendered":"<p>Have you ever wondered how to connect your applications in a Docker environment without compromising their external accessibility? Docker port forwarding emerges as a critical networking and accessibility jigsaw piece in the ever-evolving world of containerization and DevOps. In this article, we&#8217;ll break down Docker port forwarding, explain its significance, and discuss how it facilitates [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":14460,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-4635","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-privacy-security"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Docker Port Forwarding - A Network Mapping Overview<\/title>\n<meta name=\"description\" content=\"Docker port forwarding allows apps to run smoothly in other environments. If the process seems challenging, use iProVPN to bypass CGNAT limitations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker Port Forwarding - A Network Mapping Overview\" \/>\n<meta property=\"og:description\" content=\"Docker port forwarding allows apps to run smoothly in other environments. If the process seems challenging, use iProVPN to bypass CGNAT limitations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/\" \/>\n<meta property=\"og:site_name\" content=\"iProVPN Blog\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-04T07:52:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-27T10:37:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-Port-Forwarding-f.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"800\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Courtney Adams\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Docker Port Forwarding - A Network Mapping Overview\" \/>\n<meta name=\"twitter:description\" content=\"Docker port forwarding allows apps to run smoothly in other environments. If the process seems challenging, use iProVPN to bypass CGNAT limitations.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-Port-Forwarding-f.png\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Courtney Adams\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/\"},\"author\":{\"name\":\"Courtney Adams\",\"@id\":\"https:\/\/iprovpn.com\/resources\/#\/schema\/person\/551cc0751b1749749a0f3a63aa91c142\"},\"headline\":\"Docker Port Forwarding &#8211; A Network Mapping Overview\",\"datePublished\":\"2025-06-04T07:52:40+00:00\",\"dateModified\":\"2025-08-27T10:37:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/\"},\"wordCount\":1401,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/iprovpn.com\/resources\/#organization\"},\"image\":{\"@id\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-port-forwarding.jpg\",\"articleSection\":[\"Privacy &amp; Security\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/\",\"url\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/\",\"name\":\"Docker Port Forwarding - A Network Mapping Overview\",\"isPartOf\":{\"@id\":\"https:\/\/iprovpn.com\/resources\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-port-forwarding.jpg\",\"datePublished\":\"2025-06-04T07:52:40+00:00\",\"dateModified\":\"2025-08-27T10:37:09+00:00\",\"description\":\"Docker port forwarding allows apps to run smoothly in other environments. If the process seems challenging, use iProVPN to bypass CGNAT limitations.\",\"breadcrumb\":{\"@id\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#primaryimage\",\"url\":\"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-port-forwarding.jpg\",\"contentUrl\":\"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-port-forwarding.jpg\",\"width\":507,\"height\":341,\"caption\":\"Docker port forwarding\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/iprovpn.com\/resources\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Docker Port Forwarding &#8211; A Network Mapping Overview\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/iprovpn.com\/resources\/#website\",\"url\":\"https:\/\/iprovpn.com\/resources\/\",\"name\":\"iProVPN Blog\",\"description\":\"Just another WordPress site\",\"publisher\":{\"@id\":\"https:\/\/iprovpn.com\/resources\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/iprovpn.com\/resources\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/iprovpn.com\/resources\/#organization\",\"name\":\"iProVPN\",\"url\":\"https:\/\/iprovpn.com\/resources\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/iprovpn.com\/resources\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/iprovpn.com\/blog\/wp-content\/uploads\/2024\/12\/logo.png\",\"contentUrl\":\"https:\/\/iprovpn.com\/blog\/wp-content\/uploads\/2024\/12\/logo.png\",\"width\":163,\"height\":51,\"caption\":\"iProVPN\"},\"image\":{\"@id\":\"https:\/\/iprovpn.com\/resources\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/iprovpn.com\/resources\/#\/schema\/person\/551cc0751b1749749a0f3a63aa91c142\",\"name\":\"Courtney Adams\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/iprovpn.com\/resources\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2b4b94265c9fa1388acfe8a87924150ddcc4eabe5c7abf4bb7b85973674e6205?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2b4b94265c9fa1388acfe8a87924150ddcc4eabe5c7abf4bb7b85973674e6205?s=96&d=mm&r=g\",\"caption\":\"Courtney Adams\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Docker Port Forwarding - A Network Mapping Overview","description":"Docker port forwarding allows apps to run smoothly in other environments. If the process seems challenging, use iProVPN to bypass CGNAT limitations.","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:\/\/iprovpn.com\/resources\/docker-port-forwarding\/","og_locale":"en_US","og_type":"article","og_title":"Docker Port Forwarding - A Network Mapping Overview","og_description":"Docker port forwarding allows apps to run smoothly in other environments. If the process seems challenging, use iProVPN to bypass CGNAT limitations.","og_url":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/","og_site_name":"iProVPN Blog","article_published_time":"2025-06-04T07:52:40+00:00","article_modified_time":"2025-08-27T10:37:09+00:00","og_image":[{"width":1920,"height":800,"url":"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-Port-Forwarding-f.png","type":"image\/png"}],"author":"Courtney Adams","twitter_card":"summary_large_image","twitter_title":"Docker Port Forwarding - A Network Mapping Overview","twitter_description":"Docker port forwarding allows apps to run smoothly in other environments. If the process seems challenging, use iProVPN to bypass CGNAT limitations.","twitter_image":"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-Port-Forwarding-f.png","twitter_misc":{"Written by":"Courtney Adams","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#article","isPartOf":{"@id":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/"},"author":{"name":"Courtney Adams","@id":"https:\/\/iprovpn.com\/resources\/#\/schema\/person\/551cc0751b1749749a0f3a63aa91c142"},"headline":"Docker Port Forwarding &#8211; A Network Mapping Overview","datePublished":"2025-06-04T07:52:40+00:00","dateModified":"2025-08-27T10:37:09+00:00","mainEntityOfPage":{"@id":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/"},"wordCount":1401,"commentCount":0,"publisher":{"@id":"https:\/\/iprovpn.com\/resources\/#organization"},"image":{"@id":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#primaryimage"},"thumbnailUrl":"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-port-forwarding.jpg","articleSection":["Privacy &amp; Security"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/","url":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/","name":"Docker Port Forwarding - A Network Mapping Overview","isPartOf":{"@id":"https:\/\/iprovpn.com\/resources\/#website"},"primaryImageOfPage":{"@id":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#primaryimage"},"image":{"@id":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#primaryimage"},"thumbnailUrl":"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-port-forwarding.jpg","datePublished":"2025-06-04T07:52:40+00:00","dateModified":"2025-08-27T10:37:09+00:00","description":"Docker port forwarding allows apps to run smoothly in other environments. If the process seems challenging, use iProVPN to bypass CGNAT limitations.","breadcrumb":{"@id":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#primaryimage","url":"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-port-forwarding.jpg","contentUrl":"https:\/\/iprovpn.com\/resources\/wp-content\/uploads\/2023\/09\/Docker-port-forwarding.jpg","width":507,"height":341,"caption":"Docker port forwarding"},{"@type":"BreadcrumbList","@id":"https:\/\/iprovpn.com\/resources\/docker-port-forwarding\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/iprovpn.com\/resources\/"},{"@type":"ListItem","position":2,"name":"Docker Port Forwarding &#8211; A Network Mapping Overview"}]},{"@type":"WebSite","@id":"https:\/\/iprovpn.com\/resources\/#website","url":"https:\/\/iprovpn.com\/resources\/","name":"iProVPN Blog","description":"Just another WordPress site","publisher":{"@id":"https:\/\/iprovpn.com\/resources\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/iprovpn.com\/resources\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/iprovpn.com\/resources\/#organization","name":"iProVPN","url":"https:\/\/iprovpn.com\/resources\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/iprovpn.com\/resources\/#\/schema\/logo\/image\/","url":"https:\/\/iprovpn.com\/blog\/wp-content\/uploads\/2024\/12\/logo.png","contentUrl":"https:\/\/iprovpn.com\/blog\/wp-content\/uploads\/2024\/12\/logo.png","width":163,"height":51,"caption":"iProVPN"},"image":{"@id":"https:\/\/iprovpn.com\/resources\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/iprovpn.com\/resources\/#\/schema\/person\/551cc0751b1749749a0f3a63aa91c142","name":"Courtney Adams","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/iprovpn.com\/resources\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2b4b94265c9fa1388acfe8a87924150ddcc4eabe5c7abf4bb7b85973674e6205?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2b4b94265c9fa1388acfe8a87924150ddcc4eabe5c7abf4bb7b85973674e6205?s=96&d=mm&r=g","caption":"Courtney Adams"}}]}},"_links":{"self":[{"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/posts\/4635","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/comments?post=4635"}],"version-history":[{"count":27,"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/posts\/4635\/revisions"}],"predecessor-version":[{"id":17366,"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/posts\/4635\/revisions\/17366"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/media\/14460"}],"wp:attachment":[{"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/media?parent=4635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/categories?post=4635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iprovpn.com\/resources\/wp-json\/wp\/v2\/tags?post=4635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}