title: docker composer gateway to local host
body: <p>I'm running a redis tunnel on my local machine. I want my container to connect to my local machine to then connect to the redis tunnel so that my redis credentials are kept locally.</p>
  <p>Here is my docker-compose.yml</p>
  <pre><code>version: '3.8'
  
  services:
  
        front:
      container_name: front_fr
      build:
        context: docker
      volumes:
        - &quot;.:/var/www/front:rw,cached&quot;
      environment:
        - APPLICATION_ENV=dev
      ports:
        - &quot;443:443&quot;
        - &quot;6379:6379&quot;
      extra_hosts:                                                                                                                                                                            
        - &quot;redis.XXXX.amazonaws.com:172.23.0.1&quot;                                                                            
        
  </code></pre>
  <p>This works fine. But I had to install iproute 2 on the container and run ip route to get the route (172.23.0.1) and add it to the extra_hosts:</p>
  <pre><code>   docker exec e09f640bfd0d apt-get install -y iproute2                                                                                             
     docker exec e09f640bfd0d ip route   
  </code></pre>
  <p>Is there a way to add the gateway automatically without having to manually do these steps ?</p>
  <p>Thank you.</p>