Answer the question
In order to leave comments, you need to log in
How to view query log for mongodb running in docker?
Greetings!
Have mongodb running in docker
docker-compose.yml
version: '3.1'
services:
mongo:
image: mongo
network_mode: bridge
ports:
- 27017:27017
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: myUserAdmin
MONGO_INITDB_ROOT_PASSWORD: myUserAdmin
Answer the question
In order to leave comments, you need to log in
Change Dockerfile for Mongo and run it as recommended - https://stackoverflow.com/questions/15204341/mongo...
mongod --profile=1 --slowms=1 &
log will be saved to /var/log/mongodb/ mongodb.log Go
to the mongo container and see...
In the mongo config, specify the path to the log /proc/self/fd/2
(probably you can configure it on the fly with some kind of request or pass it as a command line argument, I can’t say for sure I’m not familiar with mongo), then you can watch the logs docker logs -f container_name
or docker-compose logs -f service_name
It should work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question