3

I'm testing a container in Codeship that requires a database. Using services in codeship-services.yml I'm linking the database container to the application container. The problem is the database container is printing a lot of output that gets mixed with the output of the tests. I want to get rid of the MongoDB logs completely but MongoDB doesn't have options to do that.

I'm currently running it with mongod --quiet --setParameter logLevel=0 but getting a lot of output still.

So I'm looking for a solution on the Codeship side to suppress output from a container (service in Codeship terms). The

logging:
    driver: none

setting from docker-compose doesn't seem to work.

Here is my codeship-services.yml:

myapp:
  build:
    dockerfile: Dockerfile
    image: myapp
  cached: true
  links:
    - database

database:
  image: mongo:3.4.3
  command: mongod --quiet --logpath /tmp/mongo.log --setParameter logLevel=0
Adam Sandor
  • 382
  • 1
  • 11

2 Answers2

3

If you want to reroute the MongoDB logs to /dev/null, thereby getting rid of them entirely, you should replace the path for the log output specified by the key --logpath. For instance:

database:
  image: mongo:3.4.3
  command: mongod --quiet --logpath /dev/null
ascourtas
  • 227
  • 2
  • 10
0

If you want to get rid completely of MongoDB logs, you can redirect all output of mongod command to \dev\null.

mongod --quiet --logpath /tmp/mongo.log --setParameter logLevel=0 > /dev/null 2>&1

kstromeiraos
  • 4,659
  • 21
  • 26
  • 1
    Unfortunately this fails when I run it using `jet steps`. If I add `> /dev/null` I get he following error: about to fork child process, waiting until server is ready for connections. {ContainerRunStdout=step_name:"Test" service_name:"database"}: forked process: 16 {ContainerRunStdout=step_name:"Test" service_name:"database"}: ERROR: child process failed, exited with error number 1 – Adam Sandor Apr 12 '17 at 09:04