docker postgres installation

postgres

1
2
sudo docker pull postgres
sudo docker run --name postgres-{ContainerName} -e POSTGRES_PASSWORD=${PGPassword} -e POSTGRES_USER={Username} -p 5432:5432 -d postgres
1
2
3
4
5
6
7
8
# login
psql -U {Username} -h 127.0.0.1 -p 5432

# db interface
postgres=#

# change db
postgres=# \c DB_NAME

useful command

1
2
3
4
5
sudo docker run --name postgres-tim -e POSTGRES_USER=timqian -p 5432:5432 -d postgres
psql -f ./tools/initDB.sql
select * from model_prop_log;

psql -U timqian -h 127.0.0.1 -p 5432 [-f initDB]