I run mongo thanks to docker-compose, in which i create a volume container to store data.
All is well created, and mongo create the configdb and db folder into the volume container, but there's no file in.
Tested on mac with docker for mac 1.12RC4 and in ubuntu with docker-engine 1.11 and docker-compose 1.7.1.
here my docker-compose.yml
version: "2"
volumes:
mongo_data:
driver: local
services:
mongo:
image: mongo:latest
volumes:
- mongo_data:/data
admin:
image: mongo-express:latest
links:
- mongo:mongo
ports:
- 9000:8081
here the log of mongo
mongo_1 | 2016-07-22T03:38:53.632+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=d6769ded6139
mongo_1 | 2016-07-22T03:38:53.633+0000 I CONTROL [initandlisten] db version v3.2.8
mongo_1 | 2016-07-22T03:38:53.633+0000 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
mongo_1 | 2016-07-22T03:38:53.633+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013
mongo_1 | 2016-07-22T03:38:53.634+0000 I CONTROL [initandlisten] allocator: tcmalloc
mongo_1 | 2016-07-22T03:38:53.634+0000 I CONTROL [initandlisten] modules: none
mongo_1 | 2016-07-22T03:38:53.634+0000 I CONTROL [initandlisten] build environment:
mongo_1 | 2016-07-22T03:38:53.634+0000 I CONTROL [initandlisten] distmod: debian71
mongo_1 | 2016-07-22T03:38:53.634+0000 I CONTROL [initandlisten] distarch: x86_64
mongo_1 | 2016-07-22T03:38:53.635+0000 I CONTROL [initandlisten] target_arch: x86_64
mongo_1 | 2016-07-22T03:38:53.635+0000 I CONTROL [initandlisten] options: {}
mongo_1 | 2016-07-22T03:38:53.642+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
mongo_1 | 2016-07-22T03:38:53.719+0000 I CONTROL [initandlisten]
mongo_1 | 2016-07-22T03:38:53.719+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
mongo_1 | 2016-07-22T03:38:53.719+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
mongo_1 | 2016-07-22T03:38:53.719+0000 I CONTROL [initandlisten]
mongo_1 | 2016-07-22T03:38:53.719+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
mongo_1 | 2016-07-22T03:38:53.719+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
mongo_1 | 2016-07-22T03:38:53.719+0000 I CONTROL [initandlisten]
mongo_1 | 2016-07-22T03:38:53.726+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
mongo_1 | 2016-07-22T03:38:53.726+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
mongo_1 | 2016-07-22T03:38:53.739+0000 I NETWORK [initandlisten] waiting for connections on port 27017
mongo_1 | 2016-07-22T03:38:55.327+0000 I NETWORK [initandlisten] connection accepted from 172.20.0.3:51038 #1 (1 connection now open)
mongo_1 | 2016-07-22T03:39:11.130+0000 I NETWORK [initandlisten] connection accepted from 172.20.0.3:51046 #2 (2 connections now open)
when I access the volume from another container for example an ubuntu container with tree installed
data/
|-- configdb
`-- db
folder are well created but there is no file in it.
When accessing to the mongo docker thanks to docker exec -it agenda_mongo_1 and after installing tree, I see in the directories some files.
/data
|-- configdb
`-- db
|-- WiredTiger
|-- WiredTiger.lock
|-- WiredTiger.turtle
|-- WiredTiger.wt
|-- WiredTigerLAS.wt
|-- _mdb_catalog.wt
|-- collection-0--4814241852271583066.wt
|-- diagnostic.data
| |-- metrics.2016-07-22T04-00-54Z-00000
| `-- metrics.interim
|-- index-1--4814241852271583066.wt
|-- journal
| |-- WiredTigerLog.0000000001
| |-- WiredTigerPreplog.0000000001
| `-- WiredTigerPreplog.0000000002
|-- mongod.lock
|-- sizeStorer.wt
`-- storage.bson
That is because the mongo image has a volume on /data/db/ and /data/configdb. You'll need to do the same volumes in your data container.
Looks like this was resolved. Closing old issue.
You'll need to do the same volumes in your data container.
I did this:
volumes:
- /data/db:/data/db
But it's still not working. Files are saved to the container's /data/db while the host's /data/db stays empty. Or did I do the volume declaration wrong?
Out of curiosity, why are default volumes declared in the Dockerfile anyway?
I used Docker 17.06.0-ce.
Most helpful comment
I did this:
But it's still not working. Files are saved to the container's /data/db while the host's /data/db stays empty. Or did I do the volume declaration wrong?
Out of curiosity, why are default volumes declared in the Dockerfile anyway?
I used Docker 17.06.0-ce.