title: Docker and connections between containers
body: <p>I'm trying create connections between docker's containers. One container with php5-fpm and second with nginx.</p>
  
  <p>Config for php5-fpm default, just few changes:</p>
  
  <pre><code>listen = 9000
  
  listen.allowed_clients =
  </code></pre>
  
  <p>and nginx (/etc/nginx/sites-available/default):</p>
  
  <pre><code>server {
      listen 80 default_server;
      #listen [::]:80 default_server ipv6only=on;
  
      root /var/www/testing;
      index index.php
  
      # Make site accessible from http://localhost/
      server_name localhost;
  
      location / {
          try_files $uri $uri/ /index.php;
      }
  
      location ~ \.php$ {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  
          #fastcgi_pass unix:/var/run/php5-fpm.sock;
          fastcgi_pass 192.168.1.2:9000;
          fastcgi_index index.php;
          include fastcgi_params;
      }
  
  }
  </code></pre>
  
  <p>Then i tried create connections with <a href="https://github.com/jpetazzo/pipework" rel="noreferrer">https://github.com/jpetazzo/pipework</a>, that's why <code>fastcgi_pass 192.168.1.2:9000;</code>.I tried with IP direct from container, but nothing.</p>
  
  <p>and when i'm trying open page with lynx i have BadGateway.</p>
  
  <p>I tried post port MASTER_PORT=$(sudo docker port $MASTER_ID 9000), but nothing...
  ping goes with no problem. Telnet to port 9000 from nginx keeps open few seconds and then "Connection closed by..."</p>
  
  <p>Who could explain what i'm doing wrong?
  Thx!</p>
  
  <p>/<em>EDIT</em>/
  I tried change fastcgi_pass to 172.17.42.1:9000; (address for docker0 on host machine) and then start  tcpdump on host machine:</p>
  
  <p>tcpdump -i docker0 port 9000</p>
  
  <p>and i have:</p>
  
  <pre><code>tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
  listening on docker0, link-type EN10MB (Ethernet), capture size 65535 bytes
  10:24:54.529572 IP 172.17.0.20.40932 &gt; 172.17.42.1.9000: Flags [S], seq 141160046, win 14600, options [mss 1460,sackOK,TS val 1235770 ecr 0,nop,wscale 7], length 0
  10:24:54.529594 IP 172.17.42.1.9000 &gt; 172.17.0.20.40932: Flags [S.], seq 2944341886, ack 141160047, win 14480, options [mss 1460,sackOK,TS val 1235770 ecr 1235770,nop,wscale 7], length 0
  10:24:54.529605 IP 172.17.0.20.40932 &gt; 172.17.42.1.9000: Flags [.], ack 1, win 115, options [nop,nop,TS val 1235770 ecr 1235770], length 0
  10:24:54.530324 IP 172.17.0.20.40932 &gt; 172.17.42.1.9000: Flags [P.], seq 1:665, ack 1, win 115, options [nop,nop,TS val 1235771 ecr 1235770], length 664
  10:24:54.530387 IP 172.17.42.1.9000 &gt; 172.17.0.20.40932: Flags [.], ack 665, win 124, options [nop,nop,TS val 1235771 ecr 1235771], length 0
  10:24:54.530534 IP 172.17.42.1.44233 &gt; 172.17.0.12.9000: Flags [S], seq 1354597292, win 14600, options [mss 1460,sackOK,TS val 1235771 ecr 0,nop,wscale 7], length 0
  10:24:54.530549 IP 172.17.0.12.9000 &gt; 172.17.42.1.44233: Flags [R.], seq 0, ack 1354597293, win 0, length 0
  10:24:54.531044 IP 172.17.42.1.9000 &gt; 172.17.0.20.40932: Flags [R.], seq 1, ack 665, win 124, options [nop,nop,TS val 1235771 ecr 1235771], length 0
  </code></pre>
  
  <p>Thus packets goes between containers...but why BadGateway?</p>