This is a personal collection of things I dont’t want to forget such as how I install and run things.

Docker

How I use it on my mid 2012 MBP

Installation

Note: requires virtualbox (and of course homebrew installed).

brew install docker
brew install docker-machine
docker-machine create --driver virtualbox default

From: https://medium.com/crowdbotics/a-complete-one-by-one-guide-to-install-docker-on-your-mac-os-using-homebrew-e818eb4cfc3

sudo mkdir /etc/vbox
sudo vi /etc/vbox/networks.conf

cat /etc/vbox/networks.conf
* 10.0.0.0/8 192.168.0.0/16
* 2001::/64

From: https://jongsma.wordpress.com/2021/11/29/docker-and-the-virtualbox-host-only-networks/

Run/Stop

docker-machine start default
docker-machine env default
eval $(docker-machine env default)
docker-machine stop default

postgres

docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres

From: https://stackoverflow.com/a/37704532/1845671

schemaspy

This creates a diagram of your database

docker run -v `pwd`/diagram:/output schemaspy/schemaspy:snapshot -t pgsql --port 5432 -u postgres -db <the_database> -host <the host> -p mysecretpassword

commands

Description Command
List containers, even stoped docker ps -a
List images docker images
List container ips docker inspect -f '{{.Name}}-{{.NetworkSettings.IPAddress }}' $(docker ps -aq)

postgres

psql (postgres client)

this installs the client without the database

brew install libpq
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.zshrc

From: https://stackoverflow.com/a/49689589/1845671

psql commands

Description Command
Connect psql -h localhost -p 5432 -U postgres
Connect to database psql -h localhost -p 5432 -U postgres -d demo
Run sql script psql -h localhost -p 5432 -U postgres -f demo-small-en-20170815.sql
Back up database pg_dump -h localhost -p 5432 -U postgres -W -F p the_database > new_file.sql