basic usage of psycopg

Basic module usage — Psycopg 2.9.9 documentation


close and remove a container

docker stop "CONTAINTER ID"
docker rm "CONTAINER ID"

Use docker ps -a to see all containers


host, container

docker run -p 127.0.0.1:80:8080/tcp
This means to bind port 8080 of the container to TCP port 80 on 127.0.0.1 of the host machine.


Any installation in a running container will be lost as soon as exiting the container

dockerfile - Install package in running docker container - Stack Overflow


add port tunneling between mac (local) and linux (remote) insidee a linux (remote), i.e. I ssh into linux (remote) from mac (local)

press shift and ~ and c. Hold shift while hitting ~ and c.
-L 8888:hotcake:8888 : connect mac’s 8888 to hotcake’s (server) 8888.
openssh - Add port forwarding to a running SSH session - Unix & Linux Stack Exchange


multiple port tunneling when ssh

ssh -L forward multiple ports - Stack Overflow


how to find a docker host machine’s ip address from inside a container?

sudo ip addr show docker0 gives ip address of docker host machine (in my case 172.17.0.1)
Also can identify ip address by docker network inspect bridge
Both commands above are run in hotcake (the machine sshed into)
To see an ip address of a container, run ip addr show eth0 inside a container.

  • ex: root@e77f6a1b3740:/# ip addr show eth0

nginx - From inside of a Docker container, how do I connect to the localhost of the machine? - Stack Overflow


03. Model Registry 2) Save Model to Registry

os.environ["MLFLOW_S3_ENDPOINT_URL"] = "http://172.17.0.1:9005" # when running in a container, should use host ip address instead of localhost?
os.environ["MLFLOW_TRACKING_URI"] = "http://172.17.0.1:5001"

Orignal version uses "http://localhost:9005" and "http://localhost:5001". 9005 and 5001 are ports of Linux (remote machine) and are connected to 9091 and 9092 of mac (local) individually.


How to debug inside a container with vscode

https://www.youtube.com/watch?v=w77D5KuJ7eE

I think there are two ways: 1) access to a container with vscode from local (mac) (Note: local = localhost = mac. host = Ubuntu). 2) access to a conatiner with vscode from remote (linux); need to ssh from mac first (Note: remote = host. remote is used in the context of ssh whereas host is Docker context).

Method 1): follow the video

Method 2):

  • Install Remote Development extension (I thought, for this method, the extension should be installed in linux machine but accessing container also works when the extension is installed on mac)
  • click a bottom left button and select access to running container
  • choose a container (only currently running containers are visible)

Pushing to a repo that I cloned from someone else’s

https://stackoverflow.com/questions/18200248/cloning-a-repo-from-someone-elses-github-and-pushing-it-to-a-repo-on-my-github

  1. Create a new repository at http://github.com (don’t initialize README, .gitignore, license)
  2. Clone a repo of someone else’s to my local machine
    git clone