Answers: <p>A container can access services on the host network without any additional configuration.</p>
  <p>To provide your host -- or other hosts on your network -- access to containerized services, you would typically publish a container port on the host. E.g., if you have a frontend proxy and then a number of internal backend containers, your proxy container would publish a port to the host...</p>
  <pre><code>docker run --name frontend -p 8080:80 ...
  </code></pre>
  <p>...so that you can access the proxy at <code>http://&lt;some_address_of_the_host&gt;:8080</code>.</p>
  <p>See the documentation <a href="https://docs.docker.com/guides/docker-concepts/running-containers/publishing-ports/" rel="nofollow noreferrer">here</a> for more information and examples.</p>
  
Answers: CC BY-SA 4.0
Answers: 2024-07-30T02:19:46.737Z
Answers: So does the -p argument override the argument to have the container run on the internal network?
Answers: maxical
Answers: CC BY-SA 4.0
Answers: 2024-07-30T02:24:10.447Z
Answers: No. It sets up port forwarding from the host port to the container port. The container continues to run on the internal container network.
Answers: larsks
Answers: CC BY-SA 4.0
Answers: 2024-07-30T02:26:08.223Z
Answers: Ok, so the internal network is still up except for the ports listed in the -p command which go directly to host?
Answers: maxical
Answers: CC BY-SA 4.0
Answers: 2024-07-30T02:27:45.973Z
Answers: No. Nothing about the container changes. Your application continue to listen on their ports on the internal network. Port publishing sets up port **forwarding** on the host -- so that connections to the specified host port will be forwarded/proxied to the appropriate container port (generally through the application of some netfilter rules by the docker daemon).
Answers: larsks
Answers: CC BY-SA 4.0
Answers: 2024-07-29T18:30:43.313Z
Answers: 2024-07-29T18:30:43.313Z
Answers: larsks
Body: <p>I am confused on how you set up a docker container so that you can access both your host network and an internal network of containers?</p>
  <p>Ex let's say you want container 1 to act as a proxy between internal containers network and outside.</p>
  <p>How is this done?</p>
  
Tags: <docker><networking><network>
Title: Docker container to accessing host and internal network
UserDisplayName: maxical
ThreadText: # Docker container to accessing host and internal network
  
  (Asked by: username_0 on 2024-07-29)
  
  I am confused on how you set up a docker container so that you can access both your host network and an internal network of containers?
  
  Ex let's say you want container 1 to act as a proxy between internal containers network and outside.
  
  How is this done?
  
  **Tags:** docker, networking, network
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-07-29. Score: 1 | Accepted answer
  
  A container can access services on the host network without any additional configuration.
  
  To provide your host -- or other hosts on your network -- access to containerized services, you would typically publish a container port on the host. E.g., if you have a frontend proxy and then a number of internal backend containers, your proxy container would publish a port to the host...
  
  ```
  docker run --name frontend -p 8080:80 ...
  
  ```
  
  ...so that you can access the proxy at `http://<some_address_of_the_host>:8080`.
  
  See the documentation [here](https://docs.docker.com/guides/docker-concepts/running-containers/publishing-ports/) for more information and examples.
  
  > **Comments:**
  > **username_0**: So does the -p argument override the argument to have the container run on the internal network?  
  > **username_1**: No. It sets up port forwarding from the host port to the container port. The container continues to run on the internal container network.  
  > **username_0**: Ok, so the internal network is still up except for the ports listed in the -p command which go directly to host?  
  > **username_1**: No. Nothing about the container changes. Your application continue to listen on their ports on the internal network. Port publishing sets up port **forwarding** on the host -- so that connections to the specified host port will be forwarded/proxied to the appropriate container port (generally through the application of some netfilter rules by the docker daemon).  
  
  ---
  
  