Last active
January 10, 2016 22:58
-
-
Save alexturek/f4752283cb87ced581fc to your computer and use it in GitHub Desktop.
Run Postgres in docker, but expose it locally like it's native
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make a VirtualBox VM with enough memory | |
docker-machine create --driver virtualbox --virtualbox-memory 8096 default | |
# Map the VirtualBox VM ports 5432 to localhost | |
VBoxManage controlvm default natpf1 "tcp-port5432,tcp,,5432,,5432" | |
# If this VM will be reused, bake port mapping into the VM | |
VBoxManage modifyvm default --natpf1 "tcp-port5432,tcp,,5432,,5432" | |
# Run a Postgres instance | |
# docker run -d --name "postgres-in-docker" -e POSTGRES_USER=`whoami` -p 5432:5432 postgres | |
# If you want postgis installed (I do) | |
# docker run -d --name "postgres-in-docker" -e POSTGRES_USER=`whoami` -p 5432:5432 mdillon/postgis:9.4 | |
# Does this work? | |
psql -h localhost -c "select 1;" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
docker-machine start default
- sometimes you can just restart the VM on startup