Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store --wiredTigerCacheSizeGB to mongod.conf by docker-composer

Tags:

I created docker-compose.yml to create mongo container:

version: '3'
services :
  mongo:
    image: mongo:4.2.0
    command: mongod --wiredTigerCacheSizeGB 1.5
    volumes:
      - d:/datadir/mongo:/data/configdb
    ports:
      - "27018:27017"

I limited wireTigerCach. But after up when i entered to etc/ directory inside container, i can not find mongo.config file?

root@038321c42774:/# ls -a /etc/
.             apt                     debconf.conf    fstab     gss        issue         ldap           logrotate.d       networks       passwd     rc2.d  resolv.conf  shadow-  sysctl.conf
..            bash.bashrc             debian_version  gai.conf  host.conf  issue.net     legal          lsb-release       nsswitch.conf  passwd-    rc3.d  rmt          shells   sysctl.d
.pwd.lock     bindresvport.blacklist  default         group     hostname   kernel        libaudit.conf  machine-id        opt            profile    rc4.d  securetty    skel     systemd
X11           ca-certificates         deluser.conf    group-    hosts      ld.so.cache   localtime      mke2fs.conf       os-release     profile.d  rc5.d  security     ssl      terminfo
adduser.conf  ca-certificates.conf    dpkg            gshadow   init.d     ld.so.conf    logcheck       mongod.conf.orig  pam.conf       rc0.d      rc6.d  selinux      subgid   timezone
alternatives  cron.daily              environment     gshadow-  inputrc    ld.so.conf.d  login.defs     mtab              pam.d          rc1.d      rcS.d  shadow       subuid   update-motd.d
root@038321c42774:/# 

There is mongod.conf.orig but where is mongod.conf and where stored --wiredTigerCacheSizeGB 1.5 ?

like image 944
Cyrus the Great Avatar asked Sep 04 '19 07:09

Cyrus the Great


1 Answers

from the Docs

For a more complicated configuration setup, you can still use the MongoDB configuration file. mongod does not read a configuration file by default, so the --config option with the path to the configuration file needs to be specified. Create a custom configuration file and put it in the container by either creating a custom Dockerfile FROM mongo or mounting it from the host machine to the container. See the MongoDB manual for a full list of configuration file options.

For example, /my/custom/mongod.conf is the path to the custom configuration file. Then start the MongoDB container like the following:

docker run --name some-mongo -v /my/custom:/etc/mongo -d mongo --config /etc/mongo/mongod.conf

or try set flags like this:

version: '3'
services :
  mongo:
    image: mongo:4.2.0
    volumes:
      - d:/datadir/mongo:/data/configdb
    ports:
      - "27018:27017"
    command: --wiredTigerCacheSizeGB 1.5

and the configs are not stored in any file they will be running as a flags with your command, check docker ps to see the command for your container

like image 143
LinPy Avatar answered Sep 20 '22 15:09

LinPy