Code Monkey home page Code Monkey logo

mongo-api-docker's Introduction

.Net 5.0 API using Mongo DB and Docker Compose

Prerequisites:

How to setup:

  • Clone the repo locally.
  • Using a console (powershell, bash etc) cd into the project folder
  • run the command docker-compose up
  • This will spin up two separate containers. One for the Mongo database and another for the .Net 5.0 API.
  • You can access the api on http://localhost:5000/
  • The Mongo DB runs off http://localhost:27017.
  • The docker compose uses volumes to auto create a database called ProductsDB with one collection called Products by running the /db/init_db.sh script once the container starts up.
  • This script will use the data in db.json to populate the Products collection.
  • You can use a tool such as Robo 3T: the hobbyist GUI to connect to the DB and manage the database and collections.

How to test:


Pushing to Docker Hub Repo:

If you want to push this to your own Docker Hub repository: you can follow these steps:

  1. You may need log out first docker logout then log back in using docker login.
  2. You need to include the namespace for Docker Hub to associate it with your account. The namespace is the same as your Docker Hub account name.
  3. If your image does not include your account name, you can rename it by tagging it. You can do this using docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]. e.g. docker tag dotnet-mongo-docker YOUR_DOCKERHUB_NAME/dotnet-mongo-docker:tag.
  4. You can then push your image by running this command: docker push YOUR_DOCKERHUB_NAME/dotnet-mongo-docker:tag.

Useful command:

  • docker exec -it <containername> bash - allows you to run commands in the containers. See here for more info.
  • docker tag --help - Help info to tag an image

Helpful Links:

Troubleshooting

mongo-api-docker's People

Contributors

loanburger avatar

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.