- Docker Registry
This repository is Docker Log Driver to store logs into mongoDB directly not through Logstash or Fluentd to reduce dependecies on other services.
- Docker container logs store into MongoDB.
- Set MongoDB configs by environmental variables.
- Mongo DB URL
- Database Name
- Collection name (global)
- Provide docker composer configuration
- Configure for env variable usage
- Collection name (per a service/container)
- Log format customize (TBD)
- Connection close at the end of program (including error, exception)
To build docker plugin from the source, use build script Build on Windows host is not supported.
$ ./build.sh
- in case you are stuck on plugin creation, try
sudo ./build.shinstead.
To pull plugin from DockerHub
$ docker plugin pull terua05/mongo-log-driver:0.0.3
- To see plugin's logs, plugin must be used by root account (Use
su) - Plugin's socket directory will be created in
/run/docker/plugins/${PLUGIN_ID}- Monitor stderr and stdout to see plugin's log
- Use
--log-driveroption in Docker CLIdocker run -d --log-driver mongo-log-driver:0.0.3 --log-opt use-opt=true --log-opt server="${SERVER_URI}" --log-opt dbname="${DB_NAME}" --log-opt collection="${COLLECTION_NAME}" terua05/mongo-log-driver
- Use
loggingkey to configure logging driver in docker-compose
version: '3.8'
services:
test-composer:
image: {image_name}
ports:
- 9000:9000
logging:
driver: terua/mongo-log-driver
options:
log-opt: "true"
server: "mongodb://0.0.0.0:27017"
dbname: "test-db"
collection: "collection"- To set plugin's environmental variables, we need to use
docker plugin set ${ENV_VAR}=${VALUE}.- Make sure the plugin is disabled before changing the env values.
docker plugin disable mongo-log-driver
- Make sure the plugin is disabled before changing the env values.
- Only pre-defined environmental variables are able to configured. if not, it will b e ignored.
- To check values assigned, use
docker plugin inspect mongo-log-driver
- LOG_MONGO_URL : MongoDB server address. following mongoDB documentation. (Default: mongodb://localhost:27017)
- For MongoDB Atlas (Cloud) :
mongodb+srv://[username:password@]host1[,...hostN][/[defaultauthdb][?options]]mongodb+srvprotocol will return error if port is described in the URI
- For Self-hosted :
mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
- For MongoDB Atlas (Cloud) :
- LOG_MONGO_DBNAME : Name of database (Default : docker-logs)
- LOG_MONGO_COLLECTION : Name of collection (Default : logs)
- use-opt : You must put "true" for this option to use docker log option not environmental variables. (Default : false)
- server : MongoDB server address. following mongoDB documentation.
- For MongoDB Atlas (Cloud) :
mongodb+srv://[username:password@]host1[,...hostN][/[defaultauthdb][?options]]mongodb+srvprotocol will return error if port is described in the URI
- For Self-hosted :
mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
- For MongoDB Atlas (Cloud) :
- dbname : Name of database (Default : docker-logs)
- collection : Name of collection (Default : logs)
- pressrelations/docker-redis-log-driver
- MongoDB URI syntax
- Docker Plugin Doc