Skip to content

Instantly share code, notes, and snippets.

@sueszli
Created February 15, 2026 23:54
Show Gist options
  • Select an option

  • Save sueszli/4165d5e388cf289978ea64fdcda7661b to your computer and use it in GitHub Desktop.

Select an option

Save sueszli/4165d5e388cf289978ea64fdcda7661b to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euox pipefail
CONTAINER=pg
docker rm -f $CONTAINER 2>/dev/null || true
docker run -d --name $CONTAINER --rm -e POSTGRES_PASSWORD=pass postgres:17-alpine >/dev/null
until docker exec $CONTAINER pg_isready >/dev/null 2>&1; do :; done; sleep 1
# run stuff
docker exec $CONTAINER psql -U postgres -c "CREATE TABLE fruits (fruit TEXT);"
docker exec $CONTAINER psql -U postgres -c "INSERT INTO fruits VALUES ('apple'), ('orange'); SELECT * FROM fruits;"
docker exec $CONTAINER psql -U postgres -c "SELECT * FROM fruits;"
docker stop $CONTAINER >/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment