Reputation: 7039
Im trying to use pgAdmin to connect to my postgres container in my docker image. But I cant seem to get it to connect. Here is my docker-compose.yml:
version: '2'
services:
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/livingrecipe
ports:
- '3000:3000'
env_file:
- .env
links:
- postgres
- elasticsearch
postgres:
image: postgres
elasticsearch:
image: elasticsearch
I have searched around and it looks like the localhost:5432 doesnt work unless inside the VM, but I cant find the VM IP. Looking in Kitematic under the ports this is what it shows:
Ive tried specifying the ports in the docker-compose.yml file but then I get an annoying error that says the ports are already allocated and cant figure out for the life of me what is using those ports so not sure whats going on there. Any help pointing me in the right direction either getting pgAdmin to work or just another way for me to access the database through gui like pgAdmin
Upvotes: 2
Views: 1530
Reputation: 2401
You could do in your shell:
docker ps
This will give you the list of the images you have on your machine. Choose the container id of postgres image and type to the shell:
docker inspect <container_id>
This will give you the hash with info for your image. Find the IPAddress key. Use in pgadmin that IP and the port you've specified before (5432 I guess).
Upvotes: 5