testcontainers / testcontainers-node

Testcontainers is a NodeJS library that supports tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.com
MIT License
1.86k stars 182 forks source link

[NodeJS] [@testcontainers/mysql] No longer starts on MacOS #823

Open bokjo opened 3 weeks ago

bokjo commented 3 weeks ago

Expected Behaviour

MySQL container should start and successfully connect to the Docker Desktop container ...

Actual Behaviour starting the container throws an error:

 Error: (HTTP code 404) no such container - No such container: 62b3884112f3e4196bfd61a98b41c58fe984b1ba506f3ef812d62c4487d4b5cf 
          at /Users/bojanche/[REDACTED]/node_modules/docker-modem/lib/modem.js:343:17
          at IncomingMessage.<anonymous> (/Users/bojanche/[REDACTED]/node_modules/docker-modem/lib/modem.js:370:9)
          at IncomingMessage.emit (node:events:532:35)
          at endReadableNT (node:internal/streams/readable:1696:12)
          at processTicksAndRejections (node:internal/process/task_queues:90:21) {
        reason: 'no such container',
        statusCode: 404,
        json: null
      }

...

Testcontainer Logs Cannot be fetched, the container in Docker attempts to start for a split second but it is gone ...

Steps to Reproduce Container start code:

const mySqlContainer = await new MySqlContainer(
      process.env.MYSQL_TEST_CONTAINER_IMAGE ? process.env.MYSQL_TEST_CONTAINER_IMAGE : "mysql:5.7",
    )
      .withUsername("user")
      .withUserPassword("userpw")
      .withRootPassword("rootpw")
      .withDatabase(dbName || "cart")
      .withCommand(["--sql-mode=NO_ENGINE_SUBSTITUTION"])     
      .withExposedPorts(3306)
      .start();

Environment Information

p.s btw it is fine on Linux ( GitLab CI runner)!

cristianrgreco commented 2 weeks ago

You'll need to provide more info. The error says that the container doesn't exist, add a log consumer to the container or add a breakpoint and look at the container logs to see why it is exiting. The MySQL container runs as part of the build and doesn't have an issue, so it must be environment specific.