Skip to content

Instantly share code, notes, and snippets.

@ddrscott
Created February 26, 2018 23:40
Show Gist options
  • Select an option

  • Save ddrscott/2334876fdf3f73045a7c5fcccff6fee1 to your computer and use it in GitHub Desktop.

Select an option

Save ddrscott/2334876fdf3f73045a7c5fcccff6fee1 to your computer and use it in GitHub Desktop.
FROM postgres:9.3-alpine
# Build scratch.sql by running:
# $ pg_dump --no-owner --no-acl scratch > scratch.sql.gz
COPY scratch.sql /docker-entrypoint-initdb.d/
# Change to gist directory
cd /path/to/scratch-pg93
# Build the Image
docker build -t scratch-pg93 .
# Start PG server listening to 25432
docker run -it --rm -p 25432:5432 scratch-pg93
# List table
docker run -it --rm scratch-pg93 psql -h docker.for.mac.localhost -p 25432 -U postgres -c '\d'
# Connect to it
docker run -it --rm scratch-pg93 psql -h docker.for.mac.localhost -p 25432 -U postgres
# docker.for.mac.localhost can be changed to localhost on Linux hosts.
docker run -it --rm scratch-pg93 psql -h localhost -p 25432 -U postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment