title: docker php mongodb passing links to mongodb connection
body: <p>I am trying to connect to mongodb from PHP 7.</p>
  
  <p>I have nginx container, php-fpm container and mongodb container.</p>
  
  <p>I installed mongodb driver using pecl and it is showing up in phpinfo(), mongodb ver. 1.2.3. Additionally I installed mongodb/mongodb using composer.</p>
  
  <p>I linked my containers to mongodb (eg <code>--link mongodb_container:mongodb</code>)</p>
  
  <p>Now when i am trying to: </p>
  
  <pre><code>$collection = (new Client('mongodb'))-&gt;streamflixmongodb-&gt;videos;
  </code></pre>
  
  <p>I would get an error: </p>
  
  <pre><code>Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: 
  Failed to parse MongoDB URI: 'mongodb' in /vendor/mongodb/mongodb/src/Client.php:81 Stack trace: 
  #0 /vendor/mongodb/mongodb/src/Client.php(81): MongoDB\Driver\Manager-&gt;__construct('mongodb', Array, Array) 
  #1 /var/www/html/test.php(24): MongoDB\Client-&gt;__construct('mongodb') 
  #2 {main} thrown in /vendor/mongodb/mongodb/src/Client.php on line 81
  </code></pre>
  
  <p>Because connections should start with mongodb://</p>
  
  <p>Additionally if I try to:</p>
  
  <pre><code>$collection = (new Client('mongodb://mongodb:27015'))-&gt;streamflixmongodb-&gt;videos;
  </code></pre>
  
  <p>I will get the following error:</p>
  
  <pre><code>Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: 
  No suitable servers found (`serverSelectionTryOnce` set): 
  [connection timeout calling ismaster on 'mongodb:27015'] in
  /vendor/mongodb/mongodb/src/Collection.php:513 Stack trace: #0 
  /vendor/mongodb/mongodb/src/Collection.php(513): 
  MongoDB\Driver\Manager-&gt;selectServer(Object(MongoDB\Driver\ReadPreference))
  #1 /var/www/html/test.php(27): MongoDB\Collection-&gt;find('.mp4') 
  #2 {main} thrown in /vendor/mongodb/mongodb/src/Collection.php on line 513
  </code></pre>
  
  <p>The errors are generated when I run:</p>
  
  <pre><code>var_dump($collection-&gt;find());
  </code></pre>
  
  <p>What is the right way to pass links to new mongodb in PHP? Previously I used older mongo with php5 and it was fine. </p>
  
  <p>my docker ps -a</p>
  
  <pre><code>93ce6947f2d8        vignatjevs/nginx        "/bin/sh -c 'servi..."   2 days ago          Up 57 seconds              0.0.0.0:8082-&gt;80/tcp, 0.0.0.0:32814-&gt;443/tcp         streamflix
  569307612b50        vignatjevs/php-fpm      "/app-entrypoint.s..."   2 days ago          Up 2 minutes               9000/tcp                                             streamflix-php-fpm
  03decea6dfa7        composer                "/docker-entrypoin..."   2 days ago          Exited (0) 2 minutes ago                                                        composer
  c01b48fcdda3        jenkins                 "/bin/tini -- /usr..."   3 days ago          Up 21 hours                50000/tcp, 0.0.0.0:49001-&gt;8080/tcp                   clever_swartz
  d16ace0397be        tutum/mongodb           "mongod --smallfiles"    6 days ago          Up 21 hours                0.0.0.0:27017-&gt;27017/tcp, 0.0.0.0:28017-&gt;28017/tcp   mongodb_streamflix
  72e7bca2e2b7        phpmyadmin/phpmyadmin   "/run.sh phpmyadmin"     12 days ago         Up 21 hours                0.0.0.0:8080-&gt;80/tcp                                 streamflix_admin
  a0988be5018a        centurylink/mysql       "/usr/local/bin/run"     12 days ago         Up 21 hours                0.0.0.0:3306-&gt;3306/tcp, 0.0.0.0:6603-&gt;3306/tcp       streamflix-mysql-server
  </code></pre>