Python3 and MongoDB using Docker
21st July, 2017
Dockerfile for Python3 and MongoDB using Ubuntu
FROM ubuntu:16.04
MAINTAINER www.shubhamdipt.com
# Install MongoDB.
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 && \
echo 'deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse' > /etc/apt/sources.list.d/mongodb-org-3.2.list
RUN apt-get -y update \
&& apt-get install -y --allow-unauthenticated mongodb-org \
&& apt-get install -y git vim wget python3-pip python3-dev \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip
RUN apt-get clean
# Define mountable directories.
VOLUME ["/data/db"]
ADD . /data
WORKDIR /data
RUN pip install -r requirements.txt
ENV PYTHONPATH='.'
EXPOSE 5000
RUN chmod +x ./start.sh
CMD ["./start.sh"]
and in the start.sh file add the following:
#!/usr/bin/env bash
set -eu
echo "Starting MONGOD and Flask App ...."
mongod & python3 app.py
and in the docker-compose.yml:
version: '2'
services:
web:
build: .
ports:
- "5000:5000"