Last active
June 14, 2023 19:30
-
-
Save jaso514/b7bf419ca9755cc8b24e35c2a993ea47 to your computer and use it in GitHub Desktop.
Dockerfile to create container with mongodb and python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dockerizing Python and MongoDB | |
# Based on ubuntu:latest, installs MongoDB following the instructions from: | |
# http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ | |
# INSTRUCTIONS: | |
# - Create the contianer: | |
# > docker build -t ubuntu_pymongo . | |
# - Create a folder to share your project in your host with the container. Ex: ~/shared | |
# - Run the next command (need the route of the created shared folder), this command access to the bash of container: | |
# > docker run -v /c/Users/Jhonny/Documents/vm_share/mongoDB/shared:/data/code -t -i -p 27019:27017 ubuntu_pymongo | |
# - To open another bash console run the command: | |
# > docker exec -it <id_contenedor> bash | |
# - Run the mongo database: | |
# > mongod | |
# - To connect compass or another gui with mongo use the IP of docker: 192.168.99.100 and the port 27019, or another that you indicate in the command | |
# https://stackoverflow.com/questions/33558506/how-to-create-a-mongo-docker-image-with-default-collections-and-data | |
# https://stackoverflow.com/questions/43575295/how-to-import-data-to-mongodb-container-and-creating-an-image | |
FROM ubuntu:16.04 | |
MAINTAINER Docker | |
# Installation: | |
RUN apt-get update && apt-get install -y build-essential python2.7 | |
RUN apt-get install -y python-setuptools | |
RUN apt-get install -y python-pip | |
RUN apt-get install -y nano | |
RUN apt-get install -y telnet | |
RUN apt-get install -y vim | |
# Import MongoDB public GPG key AND create a MongoDB list file | |
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv 7F0CEB10 | |
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/10gen.list | |
# Update apt-get sources AND install MongoDB | |
RUN apt-get update && apt-get install -y mongodb-org | |
# Create the MongoDB data directory | |
RUN mkdir -p /data/db | |
# Create the MongoDB data directory | |
RUN mkdir -p /data/code | |
RUN pip install bottle | |
RUN pip install pymongo | |
# Expose port #27017 from the container to the host | |
EXPOSE 27017 | |
# Set /usr/bin/mongod as the dockerized entry-point application | |
ENTRYPOINT ["/bin/bash"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks !