Custom mongod.conf gives me an error

> docker run --rm   --name psmdb  -e MONGO_INITDB_ROOT_USERNAME_FILE=/var/run/secrets/user -e MONGO_INITDB_ROOT_PASSWORD_FILE=/var/run/secrets/pass -e MONGO_INITDB_DATABASE=test -v /home/favas/percona-mongo/secrets:/var/run/secrets -v /home/favas/percona-mongo/mongod.conf:/etc/mongod.conf  percona/percona-server-mongodb:4.4 --config=/etc/mongod.conf
> parse error: Invalid numeric literal at line 2, column 6
> parse error: Invalid numeric literal at line 2, column 6
> Unrecognized option: t.$date
> try 'mongod --help' for more information

Custom mongod.conf

> # mongod.conf, Percona Server for MongoDB
> # for documentation of all options, see:
> #   http://docs.mongodb.org/manual/reference/configuration-options/
> 
> # Where and how to store data.
> storage:
>   dbPath: /var/lib/mongodb
>   journal:
>     enabled: true
> #  engine: wiredTiger
> #  engine: inMemory
> 
> # Storage engine various options
> #  More info for wiredTiger: https://docs.mongodb.com/v4.4/reference/configuration-options/#storage-wiredtiger-options
> #  wiredTiger:
> #    engineConfig:
> #      cacheSizeGB: 1
> #      checkpointSizeMB: 1000
> #      statisticsLogDelaySecs: 0
> #      journalCompressor: snappy
> #      directoryForIndexes: false
> #    collectionConfig:
> #      blockCompressor: snappy
> #    indexConfig:
> #      prefixCompression: true
> 
> #  More info for inMemory: https://www.percona.com/doc/percona-server-for-mongodb/4.4/inmemory.html#configuring-percona-memory-engine
> #  inMemory:
> #    engineConfig:
> #      inMemorySizeGB: 1
> #      statisticsLogDelaySecs: 0

# Two options below can be used for wiredTiger and inMemory storage engines
#setParameter:
#    wiredTigerConcurrentReadTransactions: 128
#    wiredTigerConcurrentWriteTransactions: 128

# where to write logging data.
#systemLog:
#  destination: file
#  logAppend: true
#  path: /var/log/mongo/mongod.log

processManagement:
  fork: true
  pidFilePath: /var/run/mongod.pid

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

I want to run the docker image with the custom configuration . currently i am adjusting by changing the CMD entry to this so that i can use the below dbpath in dockerfile
CMD [“mongod”, “–dbpath”, “/var/lib/mongod”]

1 Like

Hi @favas

Could you upload the used configuration file?

1 Like

The OP is the configuration I used . the block quotes gave me that text font

1 Like

I have the same problem on a Docker image of PSMDB version 4.4.5-7 and did a little investigation. The error is thrown by “jq”.

There is a problem with this line in entrypoint.sh when a custom mongodb.conf is passed in:

mongo --norc --nodb --quiet --eval “load(’/js-yaml.js’); printjson(jsyaml.load(cat($(_js_escape “$configPath”))))” > “$jsonConfigFile”

js.yaml cannot be loaded. If you open up $jsonConfigFile, you will see the following:

{“t”:{"$date":“2021-08-12T09:27:59.080Z”},“s”:“E”, “c”:"-", “id”:22779, “ctx”:“js”,“msg”:“file [{filename}] doesn’t exist”,“attr”:{“filename”:"/js-yaml.js"}}
Error: error loading js file: /js-yaml.js :
@(shell eval):1:1
exiting with code -4

The $jsonConfigFile is subsequently used below in this line, thus it generates the same error again:

elif _parse_config “$@” && jq --exit-status ‘.net.bindIp // .net.bindIpAll’ “$jsonConfigFile” > /dev/null; then

Is there any chance of fixing this problem soon?

1 Like