Docker how to run mongodb in dockerfile

I have a dockerfile that runs a maven build. I am following this guide:

So far in my dockerfile I have this: FROM maven:3-jdk-8-onbuild

  • Docker not working on Windows 10
  • FATA[0000] Get http:///var/run/docker.sock/v1.17/version: dial unix /var/run/docker.sock
  • Multiple RUN vs. single chained RUN in Dockerfile, what is better?
  • sonatype nexus docker volume error
  • Dockerfile in a Amazon EB
  • How can I run `gcloud preview app setup-managed-vms` without this error?
  • It runs the build and fails as expected because the integration tests require that the mongodb server on the localhost is running.

    My question is, what do I write in the dockerfile to create an image that has mongodb, start it before the integration tests, and stop the mongodb server after the integration tests?


  • Where to add client certificates for Docker for Mac?
  • Appcrash KERNELBASE.dll error when I try to use Microsoft Office in Docker Container
  • Access rest api endpoint docker
  • Fig kafka hostPort mapping
  • gevent not valid running Docker Registry
  • Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
  • One Solution collect form web for “Docker how to run mongodb in dockerfile”

    You could run in addition to the other statements in your Dockerfile statements to install mongodb.

    As a template you could for instance use the instructions from the tutum/mongodb Dockerfile.

    Then instead of using the mvn command directly you could call a shell script instead in which you start mongodb first, then execute mvn and as a last step stop mongodb.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.