Created
September 14, 2021 20:52
-
-
Save NovemberDev/600c28377808247dfed366d975b49fd6 to your computer and use it in GitHub Desktop.
Run a postgres db really quick in a docker container (cmd)
This file contains 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
docker network create -d bridge internal-network | |
docker pull postgres | |
docker run --network=internal-network --name postgres-db --publish 5432:5432 -e POSTGRES_PASSWORD=root -d postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you compose your other containers with this option in the docker-compose.override.yml or docker-compose.yml file:
Your connection string from within another docker container (which accesses the db from this new container) will be:
"Host=host.docker.internal;Port=5432;Database=database;Username=postgres;Pwd=root;"
Your connection string from "outside" aka the host machine (with pgAdmin) will be:
"Host=127.0.0.1;Port=5432;Database=postgres;Username=postgres;Password=root;"