Skip to content

Instantly share code, notes, and snippets.

@evaldosantos
Last active October 11, 2017 19:31
Show Gist options
  • Save evaldosantos/47057ee3934b7ad9e1b9ea10c25deb71 to your computer and use it in GitHub Desktop.
Save evaldosantos/47057ee3934b7ad9e1b9ea10c25deb71 to your computer and use it in GitHub Desktop.
// 1 - (host step) - create a new container
$APPNAME="db"
docker run -d --name $APPNAME -v $APPNAME:/var/lib/postgresql/data -e POSTGRES_PASSWORD=1234 -p 5432:5432 postgres:9.4-alpine
// after that, the container will be running in detached mode
// 2- (host step) So, you connect to it
docker exec -it $APPNAME /bin/bash
// 3 - (host step) copy file to container, here $APPNAME is the name of running container
docker cp dumpfile $APPNAME:/tmp
// 4 - once you are inside the container (step 2), run the command below
# PGPASSWORD=$DB_PASS pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d postgres /tmp/dumpfile
@evaldosantos
Copy link
Author

docker run -d --name back -v /path/to/back:/code:Z -p 9999:9999 --link db:db back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment