Guest User

Untitled

a guest
Dec 8th, 2017
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. 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.
  2.  
  3. To setup your Postgres Docker container you need to run:
  4.  
  5. ```
  6. 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
  7. ```
  8.  
  9. And to run your pgadmin instance as a Docker container:
  10. ```
  11. docker run -p 80:80 -e "PGADMIN_DEFAULT_EMAIL=user@domain.com" -e "PGADMIN_DEFAULT_PASSWORD=SuperSecret" -d dpage/pgadmin
  12. ```
  13.  
  14. Now when you go into the admin console you cannot connect to your local database server via localhost.
  15. 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.
  16.  
  17. Now if you want to connect with Diesel (Rust) then you need to use as server address 0.0.0.0
  18. If you want to connect via .NET with npgsql package you need to use a connectionstring like the following:
  19. ```
  20. var connectionString = "Server=localhost;Username=postgres;Password=mysecretpassword;Database=enterpreneurs";
  21. ```
Add Comment
Please, Sign In to add comment