Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I experienced that installing your Postgres database server on your local machine as a Docker container is not that evident. So this explains how you need to do it and what you need to take into account.
- To setup your Postgres Docker container you need to run:
- ```
- docker run -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=mysecretpassword --name postgres-server -p 5432:5432 -v pgdata:/var/lib/postgresql/data --restart=always postgres
- ```
- And to run your pgadmin instance as a Docker container:
- ```
- docker run -p 80:80 -e "PGADMIN_DEFAULT_EMAIL=user@domain.com" -e "PGADMIN_DEFAULT_PASSWORD=SuperSecret" -d dpage/pgadmin
- ```
- Now when you go into the admin console you cannot connect to your local database server via localhost.
- You need to run ```docker inspect postgres-server``` to get the IP address of the container and connect with that IP address in your admin console.
- Now if you want to connect with Diesel (Rust) then you need to use as server address 0.0.0.0
- If you want to connect via .NET with npgsql package you need to use a connectionstring like the following:
- ```
- var connectionString = "Server=localhost;Username=postgres;Password=mysecretpassword;Database=enterpreneurs";
- ```
Add Comment
Please, Sign In to add comment