Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

245
Visualizações
Very slow queries between server and database in docker

I'm trying to setup some integrations tests with docker compose. I'm using docker compose to spin up a postgres database and a nodejs server. I'm then using jest to run http requests against the server.

For some reasons that I can't explain all SQL queries (even the simplest one) are extremely slow (+ 1s).

It sounds like a communication problem between the two containers, but I can't spot it. Am I doing something wrong?

Here's my docker-compose.yml file. The server is just a simple express app

version: "3.9"
services:
  database:
    image: postgres:12
    env_file: .env
    volumes:
      - ./db-data:/var/lib/postgresql/data
    healthcheck:
      test: pg_isready -U test_user -d test_database
      interval: 1s
      timeout: 10s
      retries: 3
      start_period: 0s
  server:
    build: .
    ports:
      - "8080:8080"
    depends_on:
      database:
        condition: service_healthy
    env_file: .env
    environment:
      POSTGRES_HOST: database
      NODE_ENV: test
    init: true
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/healthcheck"]
      interval: 1s
      timeout: 10s
      retries: 3
      start_period: 0s

EDIT I'm using

Docker version 20.10.2, build 2291f61
macOs BigSur 11.1 (20C69)
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Try using Volume instead of Bind Mount for the data folder by changing this:

- ./db-data:/var/lib/postgresql/data

To this:

- db-data:/var/lib/postgresql/data

And adding this section to the end of the compose file:

volumes: 
    db-data:

You can read more about bind mounts vs volumes here

over 4 years ago · Santiago Trujillo Relatório

0

I found it. The issue is not in docker, but in the compiler. I'm using ncc and it breaks my postgres client.

I opened an issue in their repo with a minimal reproducible example

https://github.com/vercel/ncc/issues/646

Thanks a lot for your help

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda