-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MongoDb doesn't start when using volumes #138
Comments
the problem using volume is that I can't share files : like logs. I need to be able to see the files that the application will generate. |
I'm using Windows 10 PRO c:>ver Microsoft Windows [Version 10.0.14393] $ docker version Server: |
The problem is that mounting volumes from a Windows directory is done using samba/cifs, and that mongo db has certain requirements on the filesystem that are not fulfilled by cifs (ability to exclusively lock a file, msync, fsync....). I suggest that you mount your folder somewhere else in the container, and create a symlink so that logs (and logs only) are rerouted to that share |
thanks @simonferquel for the explanation. Can you help me clarify what as to be done on my side ? I saw the problem often in few forums but never a complete working solution. here my setup : windows 10 with the latest docker using hyper-v. I want to share a folder on my windows be to able to exchange files/dump with mongodb. using the command line : docker run -v c:/temp:/data/db mongo with docker volume create mongodata there is a way to transfer file from windows into the volume "mongodata" ? or do I have to create a symlink in windows 10 using mklink ? F:\test>mklink /d test-dir-sym-link test and I use this instead docker run -v c:/test:/data/db mongo ? |
You can succeed by running : Assuming you shared succesfully C drive in docker settings (using userlogin credentials) and you are logged in as userlogin : The windows host directory will be located at: |
@stfgit if I use that command it works.. but it produce the same results at creating a volume with : docker create volume... if I try that : docker run -p 27017:27017 -v c/Users/Sebastien/mongovol/db:/data/db mongo but if I use this syntax : c:>docker run -p 27017:27017 -v /Users/Sebastien/mongovol/db:/data/db mongo mongo will launch.. BUT there will still doesn't have file save on the host, only in the container. if I check in the folder : there is no folder mongovol. thanks |
I try with symbolic link but I got a new error c:\test>mklink /d mongozzz c:\test\xyz C:\test>docker run -p 27017:27017 -v c:/test/mongozzz:/data/db mongo |
Hmm I was thinking the other way around (mounting a Linux volume, into /data/db, a windows volume in /mongologs, and making a symlink in a docker file from the log folder in /data/db to the windows volume). In any case, data files can't be stored directly in the Windows volume. But what I did instead, was creating a dockerfile based on the mongo image, declare a new volume /data/logs and add parameters to mongod to push logs in this volume and mount a windows volume in it. So now I have: If I need to backup the data, I can either rely on mongodump/mongorestore. |
Here is the dockerfile:
I built the image with Now I can user |
If you want to be able to directly copy your data directory to another machine (without mongodump), you can create a named volume that you mount in /mongo/db, and while your mongo container is stopped, mount the same named volume in a separate container and copy it to a windows mounted volume. On the target machine, you just do the exact opposite. |
thanks @simonferquel for the workaround. I'll try the dockerfile solution. I was just hopping that could be solved internally with docker/mongo with buildin support. One thing that I didn't try. could it works if we mount a SMB drive in Win10 and use it as volume for mongodb ? |
That is exactly what the "Drive sharing" feature does, and unfortunately, Linux SMB support is not rich enough to support MongoDB. Another solution is to work with windows containers instead of Linux (which requires windows 10 anniversary update) and use a flavor of mongo working on Windows like mongo:windowsservercore. But we do not support (yet!) networking between Windows and Linux containers |
@survivant Are you ok if I close this issue ? |
yes. |
similar issue than for docker/for-win#138
similar issue than for docker/for-win#138
If you run this container on docker for windows and mount the mongo files as a local volumne, [mongo will crash because it can't fsync the data files](docker/for-win#138). For whatever reason this causes the curl command to hang forever and the container will eat all your CPU.
If you run this container on docker for windows and mount the mongo files as a local volumne, [mongo will crash because it can't fsync the data files](docker/for-win#138). For whatever reason this causes the curl command to hang forever and the container will eat all your CPU.
Hello Everybody, I came to the same problem as of may 2019. Delete the mongod.lock and WiredTiger.lock from the file system (volume) |
It seems that you can't mount a drive to mongo container on Windows because VirtualBox shared file system doesn't support fsync() However, what you can try is to create a volume that is mounted to a file system and use that for mongo container. I will give it a try later today. I'm using docker-compose for my application so this should be a good enough solution for dev. |
Hey everybody, are there any solutions pertinent to this "Mongo fail to mount to host when it's in Windows container" issue??? I can make mongo mount to the host if I am using linux container but I got some issues that I can access the data from the remote address, meaning that even if I "-p 27017:27017" in the command, I have the feeling that I should look for the solution that "how can I access linux container remotely" instead... Exhausting.... using this container thing.... |
Hy SeasonLeee, |
Closed issues are locked after 30 days of inactivity. If you have found a problem that seems similar to this, please open a new issue. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
I'm trying to start mongo using volume to persist the data between restarts.
I been in Docker Settings and check the C: checkbox and enter credentials.
when I start mongo db using this command line :
$ docker run -p 27017:27017 -v c:/test-mongo:/data/db mongo
I obtain the error below
2016-10-10T19:48:32.036+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=b08b1c94b8b2
2016-10-10T19:48:32.036+0000 I CONTROL [initandlisten] db version v3.2.10
2016-10-10T19:48:32.036+0000 I CONTROL [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
2016-10-10T19:48:32.036+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t 3 May 2016
2016-10-10T19:48:32.036+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-10-10T19:48:32.036+0000 I CONTROL [initandlisten] modules: none
2016-10-10T19:48:32.036+0000 I CONTROL [initandlisten] build environment:
2016-10-10T19:48:32.036+0000 I CONTROL [initandlisten] distmod: debian81
2016-10-10T19:48:32.036+0000 I CONTROL [initandlisten] distarch: x86_64
2016-10-10T19:48:32.037+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-10-10T19:48:32.037+0000 I CONTROL [initandlisten] options: {}
2016-10-10T19:48:32.048+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),
2016-10-10T19:48:32.063+0000 E STORAGE [initandlisten] WiredTiger (1) [1476128912:63941][1:0x7f7cbb986cc0], connection: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2016-10-10T19:48:32.065+0000 I - [initandlisten] Assertion: 28595:1: Operation not permitted
2016-10-10T19:48:32.066+0000 I STORAGE [initandlisten] exception in initAndListen: 28595 1: Operation not permitted, terminating
2016-10-10T19:48:32.066+0000 I CONTROL [initandlisten] dbexit: rc: 100
if I check in teh HD, I'll see that some file were created
.2016-10-10 03:48 PM
2016-10-10 03:48 PM ..
2016-10-10 03:48 PM journal
2016-10-10 03:48 PM 0 mongod.lock
2016-10-10 03:48 PM 46 WiredTiger
2016-10-10 03:48 PM 21 WiredTiger.lock
2016-10-10 03:48 PM 0 WiredTiger.wt
4 File(s) 67 bytes
BUT
if I use this command line :
docker volume create --name=mongodata
docker run -d -p 27017:27017 -v mongodata:/data/db mongo
it will works
$ docker run -p 27017:27017 -v mongodata:/data/db mongo
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=01d5334620b9
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] db version v3.2.10
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t 3 May 2016
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] modules: none
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] build environment:
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] distmod: debian81
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] distarch: x86_64
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-10-10T19:54:39.093+0000 I CONTROL [initandlisten] options: {}
2016-10-10T19:54:39.098+0000 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-10-10T19:54:39.098+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),
2016-10-10T19:54:39.306+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-10-10T19:54:39.306+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-10-10T19:54:39.306+0000 I NETWORK [initandlisten] waiting for connections on port 27017
The text was updated successfully, but these errors were encountered: