Docker Node App Postgres Error "Connection terminated unexpectedly"
I change the way I explain answer:You basically need Postgres service, in your image you don't have it, you are basically using node image without running Postgres database.
Try this docker-compose.yml
version: "3.7"services: api: container_name: api build: . depends_on: - postgres volumes: - .:/api ports: - "3000:3000" restart: unless-stopped working_dir: /api command: nodemon server.js postgres: image: postgres:10.4 ports: - "35432:5432"
Edit 1
Host machine
version: "3.7"services: api: container_name: api build: . volumes: - .:/api ports: - "3000:3000" - "5432:5432" restart: unless-stopped working_dir: /api command: nodemon server.js