Giter Club home page Giter Club logo

docker_django_mongodb's Introduction

docker_django_mongodb

Dockerize Django-MongoDB Application with docker-compose

Introduction

A Quick Start Example to run Django-MongoDB Application in Docker.

Requirements

This module requires the following modules/libraries:

  • Docker
  • Any version of Linux or Unix OS (Recommended and Optional)

Installation

Install using the following the command,

docker-compose up -d --build

What does this example teach us?

Initializing a fresh instance with MongoDB dump data

When a container is started for the first time, it will execute files with extensions .sh, and .js that are found in init_db. .js files will be executed by mongo using the database specified by the MONGO_INITDB_DATABASE variable in docker-compose.yml, if it is present, or test otherwise. You may also switch databases within the .js script.

Store MongoDB data on Host System

Directory named data_db will serve as a MongoDB data directory on the host system (outside the container). It is easy for tools and applications on the host system to access the MongoDB files from this directory. The data_db directory from host system is mounted to /data/db inside the container, where MongoDB by default will write its data files.

Perform database migration at the beginning

Using docker hierarchy in docker-compose.yml, the services make-migration and migration runs after setting up the database but before the start of the main web service. This docker configuration helps us to automatically run the django migration commands on the application once the database has been setup.

Web-based MongoDB admin interface

This example also creates a web-based user inteface for MongoDB called mongo-express through port 8081.

Troubleshooting/Issues

Known Issues:

โš ๏ธ Warning running on Windows OS

  • The default Docker setup on Windows uses a VirtualBox VM to host the Docker daemon. Unfortunately, the mechanism VirtualBox uses to share folders between the host system and the Docker container is not compatible with the memory mapped files used by MongoDB. This means that it is not possible to run a MongoDB container with the data directory mapped to the host on Windows OS.
  • As a quick work around to run this example on windows machine please comment few lines of volume mapping in docker-compose.yml.

Credits

This example uses a popular open source project called Djongo - A Django and MongoDB database connector. Thanks to the creator for this wonderful contribution.

Support

Reach out to me at one of the following places!

License

GPLv3

docker_django_mongodb's People

Contributors

balanpradeepkumar avatar

Forkers

adasdevops

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.