Multi container setup using Docker, Postgres, Conda, Flask and Jupyter Notebook
[x] spin up docker container using postgres image - run, docker run postgres
[x] run docker ps to check names
[x] in another terminal, log into the container and start psql process, docker exec -it infallible_lehmann psql -U <database username> -d <database name>. You should see something like root@b6e4e4c52f20:/#
or do then separately first run, docker exec -it <postgres container name> bash then psql -U postgres and the prompt will change
[x] run \l to see the list of databases
[x] run \c <database_name> to connect to the database
[x] install Anaconda
[x] install Jupiter Notebook
[x] install conda
[x] in another terminal run conda virtual environment, conda activate <environment-name>
[x] then run Jupiter Notebook in the conda env, run
[x] return to the terminal with the conda environment activated (it with have this (base)) and then run jupyter notebook
[x] when it opens in the browser run import psycopg2
[x] MUST create additional user and alter role as SUPERUSER
[x] to connect to database in Jupyter notebook, run conn = psycopg2.connect(host="0.0.0.0", port=5432, database="projectpages", user="postgres", password="password")
Multi container setup using Docker, Postgres, Conda, Flask and Jupyter Notebook
docker run postgres
docker ps
to check namespsql
process,docker exec -it infallible_lehmann psql -U <database username> -d <database name>
. You should see something likeroot@b6e4e4c52f20:/#
docker exec -it <postgres container name> bash
thenpsql -U postgres
and the prompt will change\l
to see the list of databases\c <database_name>
to connect to the databaseconda activate <environment-name>
(base)
) and then runjupyter notebook
import psycopg2
SUPERUSER
conn = psycopg2.connect(host="0.0.0.0", port=5432, database="projectpages", user="postgres", password="password")