PostgreSQL Exercises provides exercises for learning SQL, using a Postgres instance. This is a reference on how to setup a dedicated environment using a Docker container.
The official Docker image for Postgres will be used.
Data is persisted in a named volume PGEXERCISES
, mapped to the default path inside the container.
We aren't defining a password, as the connection will be local (from inside the container).
docker run --rm --name pgexercises -v PGEXERCISES:/var/lib/postgresql/data -d postgres
The container will run as root, but this is a non-issue in a learning environment.with
docker exec -it pgexercises bash # you will be 'inside' the container after this
psql -U postgres
wget https://pgexercises.com/dbfiles/clubdata.sql
psql -U postgres --file clubdata.sql