Skip to content

Instantly share code, notes, and snippets.

@stpettersens
Last active August 14, 2017 20:33
Show Gist options
  • Save stpettersens/8701b1b8124d7427b683 to your computer and use it in GitHub Desktop.
Save stpettersens/8701b1b8124d7427b683 to your computer and use it in GitHub Desktop.
Dockerfile for container that provides MongoDB + Node.js.
#
# Dockerfile for a container that provides Node.js and MongoDB.
# saintpettersens/nodemongodb
#
# Use Ubuntu as base for container.
FROM ubuntu
# Install MongoDB.
ENV mongorepo "http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse"
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
RUN echo "deb $mongorepo" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list
RUN apt-get update && apt-get install -y mongodb-org
# Install Node.js.
RUN apt-get install -y nodejs
# Install npm.
RUN apt-get install -y npm
# Make symbolic link to Node.js ("node").
RUN ln -s /usr/bin/nodejs /usr/bin/node
# Print MongoDB, Node.js and npm versions.
CMD mongo --version && echo "Node.js $(node --version)" && echo "npm $(npm --version)"
@mehmetyaman
Copy link

mehmetyaman commented Aug 14, 2017

Hi I think you need to add lines below before mongodb installation

RUN apt-get autoremove
RUN apt-get -f install
RUN touch /etc/init.d/mongod

otherwise it gets exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment