The document describes how to build Docker images from Dockerfiles. It explains the main Dockerfile instructions including FROM, MAINTAINER, ADD, ENV, RUN, CMD, ENTRYPOINT, EXPOSE and VOLUME. It provides examples of each instruction and concludes by showing how to build an image running MongoDB using these instructions.
10. VOLUME
VOLUME ["/data"]
The VOLUME instruction will add one or more
new volumes to any container created from
the image.
Puts /data here: /var/lib/docker/volumes/
11. Dockerfile - the main
event
# What image are we using?
FROM ubuntu
# Take some credit
MAINTAINER Tyler Brock, tyler@mongodb.com
# Add 10gen official apt source to the sources list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/10gen.list
# Hack for initctl not being available in Ubuntu
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -s /bin/true /sbin/initctl
# Install MongoDB
RUN apt-get update
RUN apt-get install mongodb-10gen
# Install a sensible config
ADD mongod.conf /etc/mongod.conf
# Setup the image as an executable that runs MongoDB
CMD ["--config", "/etc/mongod.conf"]
ENTRYPOINT ["/usr/bin/mongod"]
EXPOSE 27017