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

709
Vistas
AWS CodeBuild: How to run tests that require starting Docker?

I have a Node.js project with Testcontainers used for staring Redis and Prostgress for tests.

I want to run these tests as a part of CI. For that purpose, I use an alpine image of Node.js with Docker installed on top of it. I can run tests that don't require Docker there, but if it involves Docker, I get this error from Testcontainers:

No Docker client strategy found

Here is what I get in logs:

2022-05-25T13:09:11.494Z testcontainers DEBUG Found applicable Docker client strategy: UnixSocketStrategy
2022-05-25T13:09:11.531Z testcontainers DEBUG Testing Docker client strategy URI: unix:///var/run/docker.sock
2022-05-25T13:09:11.539Z testcontainers DEBUG No registry auth locator found for registry: "https://index.docker.io/v1/"
2022-05-25T13:09:11.543Z testcontainers WARN  Docker daemon is not reachable: Error: connect ENOENT /var/run/docker.sock
2022-05-25T13:09:11.543Z testcontainers WARN  Docker client strategy UnixSocketStrategy is not reachable
2022-05-25T13:09:11.544Z testcontainers ERROR Failed to list images: Error: No Docker client strategy found
2022-05-25T13:09:11.544Z testcontainers ERROR Failed to pull image "postgres:14.2-alpine": Error: No Docker client strategy found

The tests run fine when I start them locally.

I haven't found anything in the CodeBuild documentation explaining connecting to the Docker Engine from inside a builder container. I found these instructions in the Testcontainers documentation, but I don't understand how to apply this in AWS Codebuild.

Q: How to run tests that require starting Docker in AWS CodeBuild?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

WARN Docker daemon is not reachable: Error: connect ENOENT /var/run/docker.sock

CodeBuild environments by default:

  1. do not have access to interact with the Docker daemon, dockerd
  2. do not have the Docker daemon running

The error is hinting at this by stating that it cannot reach the daemon.

To address the above:

  1. Set your buildspec version to 0.2
  2. Run your build with privilegedMode set to true, to grant access to the daemon
  3. Ensure the daemon is running

The key point to note here is when using AWS CodeBuild provided official Docker images, the Docker daemon is automatically started via the dockerd-entrypoint.sh. You do not need to do this manually.

However, when using custom images, you must start the daemon manually.


You can manually initialise the Docker daemon during the install phase of your build by adding the below commands to your buildspec.yml file.

For an Alpine-based image:

version: 0.2

phases:
  install:
    commands:
      - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &
      - timeout -t 15 sh -c "until docker info; do echo .; sleep 1; done"
...

For a Ubuntu-based image:

version: 0.2

phases:
  install:
    commands:
      - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &
      - timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
...

You should now be able to run Docker containers within your build.

If that still doesn't work, it will be related to Testcontainers.

As per the docs you have linked, ensure your docker run ... command which is running the container includes -v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock.

about 4 years ago · Juan Pablo Isaza 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