A
A
Alexander2018-10-01 12:07:10
Docker
Alexander, 2018-10-01 12:07:10

Why can't my container communicate with postgres?

docker-compose.test.yml:

version: '3'

services:
  db:
    image: postgres
  web:
    restart: always
    image: $CONTAINER_TEST_IMAGE
    command: python3 manage.py test --noinput
    depends_on:
    - db

.gitlab-ci.yml:
...
test:
  stage: test
  script:
    - docker pull $CONTAINER_TEST_IMAGE
    - docker-compose -f docker-compose.test.yml run web
    - docker-compose rm -f web
  tags:
    - dev
...

Mistake:
could not connect to server: Connection refused
  Is the server running on host "db" (172.22.0.2) and accepting
  TCP/IP connections on port 5432?

What's the catch, if I restart Pipeline in gitlab, everything works as it should.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question