Docker Community Forums

Share and learn in the Docker community.

Cannot connect to postico from docker-compose postgresql service


(Shon3005) #1

I’ve done a docker-compose up and been able to run my web service attached to a postgresql image. Problem is, I can’t view the data on postico when I try to access the database. The name of the image is db and when i try to specify hostname to be “db” on postico before i connect, i get an error saying hostname not found. I’ve entered my credentials, port and database name the same way i keyed them in my docker-compose file.

Does anybody know how i can find the correct setup to connect to within the container?

version: '3.6'
services:
  phoenix:
    # tell docker-compose which Dockerfile it needs to build
    build:
      context: .
      dockerfile: Dockerfile.phoenix.development
    # map the port of phoenix to the local dev port
    ports:
      - 4000:4000
    # mount the code folder inside the running container for easy development
    volumes:
      - ./my_app:/app
    # make sure we start mongodb when we start this service
    # links:
    #   - db
    depends_on:
      - db
      - redis
    environment:
      GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID}
      GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET}
      FACEBOOK_CLIENT_ID: ${FACEBOOK_CLIENT_ID}
      FACEBOOK_CLIENT_SECRET: ${FACEBOOK_CLIENT_SECRET}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_USER: ${POSTGRES_USER}
  go:
    build:
      context: .
      dockerfile: Dockerfile.go.development
    ports:
      - 8080:8080
    volumes:
      - ./genesys-api:/go/src/github.com/sc4224/genesys-api
    depends_on:
      - db
      - redis
      - phoenix
  db:
    container_name: db
    image: postgres:latest
    ports:
      - "5432:5432"
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_USER: ${POSTGRES_USER}
    volumes:
      - ./data/db:/data/db
    restart: always
  redis:
    container_name: redis
    image: redis:latest
    ports:
      - "6379:6379"
    volumes:
      - ./data/redis:/data/redis
    entrypoint: redis-server
    restart: always

(Martin Terp) #2

postico is a local client, and not a container, right?

because then you can use: localhost:5432 (or host-ip if its on another machine)