Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

244
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda