Creating a DB
sudo -u postgres createdb <dbname>
Creating a role
Note that in postgres all access is managed by "roles", there is no concept of users or groups (though for historical purposes users and roles can be thought of as largely interchangeable).
Without a password:
sudo -u postgres createuser <username>
With a password:
sudo -u postgres createuser <username> -P
By default (defined in `/etc/postgresql/11/main/pg_hba.conf`), local users can authenticate without needing a password into a role with the same name as their username.
Remote users (including those connecting from other docker containers) can only connect as roles with passwords defined.
Starting an interactive session
sudo -u postgres psql <dbname>
- List all databases: