Tag: mongodb

Mongodb collection insert ignoring unique index

I have the following Image Model, built w/ mongoose, using two unique indexes: ‘use strict’; var mongoose = require(‘bluebird’).promisifyAll(require(‘mongoose’)); var Schema = new mongoose.Schema({ name: String, src: { type:String, unique: true }, height: String, width: String, importSrc: { type:String, unique: true }, status: String, // Timestamps createdAt: Date, updatedAt: Date, deletedAt: Date }); Schema.pre(‘save’, function(next){ […]

Overriding VOLUME directive in a Dockerfile

I’m building my own image on top of docker.io/mongo:3.2, but I have a problem with persisting some changes (creating new users) in the build process. I’m aware that this happens because the users are created in the /data/db, which is defined as VOLUME in the original MongoDB Dockerfile. My question is if there is a […]

Limit Disk usage in Docker+MongoDB

I am using the official mongo Docker image to start a MongoDB container where my boot disk is limited (e.g. 10G) I configured the docker to run with Google Cloud Logging driver and was hoping Google to store all the logs and save my local disk space. However, I notice the disk continues to grow: […]

How does docker-compose link work?

I have three containers, web, rest and db. I want rest (nodejs) to be able to access db (mongodb). My docker-compose.yml: version: ‘2’ services: web: build: front depends_on: – db – rest db: build: backend/mongodb volumes: – /src/docker/mongodb:/var/lib/mongodb restart: always rest: build: backend/rest restart: always links: – db:database In my nodejs program: MongoClient.connect(“mongodb://database:27017/mytest”, function (err, […]

persist and share data from docker mongo container (with docker)

Need a push in the right direction with this one. I want to “dev0ps” the workflow of our local development with docker. As best practice our mongodb should run in a seperate container, having a volume attached and working. (this part checks out fine) Our developers should then keep the data in sync, so its […]

Docker with mongo user

I’m trying to create a mongodb user for security reason. Now I have the following Dockerfile: FROM mongo:3.3 RUN mongo admin –eval “db.getSiblingDB(‘db’).createUser({user: ‘test’, pwd: ‘test’})” When I run docker I get the following error: MongoDB shell version: 3.3.5 connecting to: admin 2016-05-17T13:31:07.821+0000 W NETWORK [thread1] Failed to connect to, reason: Connection refused 2016-05-17T13:31:07.821+0000 […]

How can I use YAML objects from docker-compose as variables in DockerFile and scripts

In trying to make a nice testing lab docker-compose yaml I have run into a case where I would want to have something like: rs1-node1: image: “davidbmurphy/percona_mongodb:3.0″ config: port:1234 auth:”true” keyfile=”{{$KEY_FILE}}” replset:”rs1″ rs1-node2: image: “davidbmurphy/percona_mongodb:3.0″ config: port:1234 auth:”true” keyfile=”{{$KEY_FILE}}” replset:”rs1″ rs1-node3: image: “davidbmurphy/percona_mongodb:3.0″ config: port:1234 auth:”true” keyfile=”{{$KEY_FILE}}” replset:”rs1″ rs2-node1: image: “davidbmurphy/percona_mongodb:3.0″ config: port:1235 auth:”true” keyfile=”{{$KEY_FILE}}” […]

Docker-compose: Can I automate compose to run commands inside a container?

Okay so I know I can automate my “docker run” instructions like this, say I would do this without compose: First create the volume docker volume create –name mongodb-shard-1-node-1 Then the container docker run –name mongodb-node-1 -d -v mongodb-node-1:/data/db -p 27031:27017 –link mongo-node-2:mongo mongo –replSet rs0 –smallfiles –oplogSize 128 This would be the same as […]

Run docker mongo with read-only fs

I want to start a mongo container with a read-only fs for security reason according to 5.12. I have the following docker-compose.yml: version: ‘2’ services: mongodb: image: mongo:3.2 command: -f /etc/mongo.conf volumes: – ./mongo/mongo.conf:/etc/mongo.conf:ro – /data/db user: mongodb read_only: true On docker-compose up it fails with the error Failed to unlink socket file /tmp/mongodb-27017.sock errno:30 […]

Mongodb on samba shared directory

I’m trying to setup a mongodb database where the folder it uses for the data is a samba shared directory. But mongodb refuses to start, I get: [initandlisten] Assertion: 28595:1: Operation not permitted [initandlisten] exception in initAndListen: 28595 1: Operation not permitted, terminating Is there anything I can do ? Thank you

Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.