0

I have container with a NodeJS application and it has to be linked to another container with a Postgres db. My docker-compose.yml is:

version: "3"
services:
  postgres:
    image: "postgres:9.5.6-alpine"
    container_name: postgres
    volumes:
      - /shared_folder/postgresql:/var/lib/postgresql
    ports:
      - "5432:5432"  
  web:
    build: .  
    container_name: web
    ports:
      - "3000:3000"
    links:
      - postgres 
    depends_on:
      - postgres 
    command: sh /usr/home/freebsd/wait-for-command.sh -c 'nc -z postgres 5432' 
    command: sh start.sh

On postgres container there is a db named "bucket", owned by user "user" with password "password".

When I type docker-compose up, and try to link the containers, after this message from console:

[INFO] console - postgres://user:password@localhost:5432/bucket

I get this error:

Error: Connection terminated
at [object Object].<anonymous> 

in /node_modules/massive/node_modules/deasync/index.js:46

where is the problem?

1 Answer 1

1

You define command twice, which means your wait-for-command.sh is being overridden by sh start.sh and it's probably being run before PostgreSQL is ready to accept connections.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.