Building and running our MongoDB Docker service

In this section, we will be creating the Dockerfile to build MongoDB, which will have all the information, such as base image, port to be exposed, how to install the MongoDB service, and so on.

Now, let's log in to your Docker master (leader) account and create a Dockerfile with the name Dockerfile using the following contents:

    # MongoDB Dockerfile 
    # Pull base image. 
    FROM ubuntu 
    MAINTAINER Manish Sethi<manish@sethis.in> 
    # Install MongoDB. 
    RUN \ 
    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv     7F0CEB10 && \ 
    echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' > /etc/apt/sources.list.d/mongodb.list && \ apt-get update && \ apt-get install -y mongodb-org && ...

Get Cloud Native Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.