Category Archives: PostgreSQL

Postgresql in Docker

Let’s run up the Docker image with an instance of PostgreSQL

1
docker run --name mypostgres -d postgres

Now, connect to the instance so we can create a database etc.

1
docker exec -it mypostgres bash
1
createdb -U postgres MyDatabase

Note: if you find this error message psql: FATAL: role “root” does not exist, you’ll need to switch to the postgres user, see below.

Switch to the postgres user (su substitute user).

1
2
su postgres
psql

At which point, we’re now in the psql application and can create databases etc.