title: How do I connect to local machine from inside of docker container created by docker-compose?
body: <p>I have a docker container that has been created using docker-compose.  Here is the yml file.</p>
  
  <pre><code>version: "3"
  services:
    redis:
      image: "redis"
    web:
      image: "myimage"
      ports:
        - "8000:8000"
      environment:
        REDIS_HOST: redis
      volumes:
        - .:/usr/src/app
      depends_on:
        - "redis"
      command: ["npm", "start"]
  </code></pre>
  
  <p>From this container my web app needs to connect to the local machine because my local machine is running another web app that my docker container's web app needs to access.  How do I do this?  The localhost's webapp is hosted on a different port (7777).</p>
  
  <p>I have already seen <a href="https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach">From inside of a Docker container, how do I connect to the localhost of the machine?</a>, and I got it to work using "extra_hosts" option, but I want to know if there is another way to do this?</p>