Sign inSign up

moonlitaltar/cs340

By moonlitaltar

•Updated about 3 years ago

MongoDB container for SNHU class CS340.

Image
Databases & storage
0

264

moonlitaltar/cs340 repository overview

⁠Open Terminal
⁠Get Container:
docker pull moonlitaltar/cs340
⁠Run Container:

Change "container_name" to whatever you'd like the container to be called

docker run -d -p 27017:27017 --name container_name moonlitaltar/cs340  
⁠Run Commands
docker exec -it container_name bash
⁠Add user

Create a user using your SNHU handle for assignments.

useradd -m -s /bin/bash yourname_snhu
passwd yourname_snhu
su - yourname_snhu
⁠The datasets for CS340 are on the image and located at /usr/local/datasets
⁠Add MongoDB environment file to bash
echo 'source /usr/local/datasets/mongodb-env.txt' >> ~/.bashrc
source ~/.bashrc
⁠Copy mongoshrc.js file to home folder
cd /usr/local/datasets
cp mongoshrc.js ~/.mongoshrc.js
⁠Connect to mongo shell
mongosh
⁠Change root user password in MongoDB
db.changeUserPassword("root", "NewPasswordHere")
exit
exit # This exit returns to root user
⁠Edit MongoDB environment file
cd /usr/local/datasets
nano mongodb-env.txt

Change the password for MONGO_PASS from "password" to what you put in for "NewPasswordHere", use Ctrl+S to save, then Ctrl+X to exit.

⁠Change User and Test Connection
su - yourname_snhu
mongosh
⁠If it connects without errors and starts you in the admin database, that means everything is setup correctly.
⁠Install Jupyter - (You must have Python Installed with pip before continuing)
  • Either exit the container or open a new terminal. Run the following:
pip install pymongo notebook jupyter-dash dash-leaflet==0.1.9 dash==2.8.1 pandas==1.4.2 matplotlib
⁠When you get to module 4
⁠If you get errors in visual studio code about pymongo, make sure you're python interpreter path is correct, it should look something like this:
C:\Users\yournamehere\AppData\Local\Programs\Python\Python312\python.exe
⁠To Start Jupyter Notebook
  • Open your terminal and navigate to the folder where your python file is located
jupyter notebook
  • Your browser should automatically open jupyter notebook and you can proceed to making scripts

Tag summary

Content type

Image

Digest

sha256:a0d23a8ca…

Size

466.7 MB

Last updated

about 3 years ago

docker pull moonlitaltar/cs340