I was using Boot2Docker 1.2 (OSX) and wanted to use volume for MongoDB. First nothing was happening because 1.2 has no Guest Additions and volumes don't work. There is a workaround by making a boot2docker.iso from master which has Guest Additions.
But then Mongo didn't like putting data on VirtualBox's shared folders:
[initandlisten] WARNING: This file system is not supported. For further information see:
[initandlisten] http://dochub.mongodb.org/core/unsupported-filesystems
[initandlisten] Please notify MongoDB, Inc. if an unlisted filesystem generated this warning.
MongoDB requires a filesystem that supports fsync() on directories. For example, HGFS and Virtual Box’s shared folders do not support this operation.
So the easiest solutions of all and a proper way for data persistance is Data Volumes
Assuming you have a container that has VOLUME ["/data"]
# Create a data volume
docker run -v /data --name yourData busybox true
# and use
docker run --volumes-from yourData ...