Example using Mongo

Example Yaml configuration for a project with a MongoDB service dependency. Note that the mongo service will be available at mongo:27017.

pipeline:
  ping:
    image: mongo:3.0
    commands:
      - sleep 15
      - mongo --host mongo --eval "{ ping: 1 }"

services:
  mongo:
    image: mongo:3.0
    command: [ --smallfiles ]

If you are unable to connect to the mongo container please make sure you are giving mongodb adequate time to initialize and begin accepting connections.

pipeline:
  ping:
    image: mongo:3.0
    commands:
+     - sleep 15
      - mongo --host mongo --eval "{ ping: 1 }"

services:
  mongo:
    image: mongo:3.0
    command: [ --smallfiles ]

If you are still unable to connect to the mongo container, please make sure you are using the service name as the hostname.

- mongo --host localhost --eval "{ ping: 1 }"
+ mongo --host mongo     --eval "{ ping: 1 }"

Questions?

We are always happy to help with questions you might have. Search our documentation or check out answers to common questions. You can also post questions or comments to our community forum.

Is there a mistake on this page? Please let us know or edit this page.