testcontainers-node icon indicating copy to clipboard operation
testcontainers-node copied to clipboard

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

Open bokjo opened this issue 1 year ago • 1 comments

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

  • Operating System: MacOS Sonoma 14.6.1 (was the same on 14.4.1) [Intel]
  • Docker Version: 4.33.0 (160616) (Engine: 27.1.1)
  • Node version: v22.7.0 ( same outcome on v20.17.0 LTS)
  • Testcontainers version: v10.11.0 ( same outcome on v10.7.2)

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

bokjo avatar Aug 23 '24 09:08 bokjo

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.

cristianrgreco avatar Aug 28 '24 09:08 cristianrgreco

The issue was because mysql:5.7 image is not an ARM-compatible image.

But there was no useful error message to understand it easily, even with extra logs enabled.

Hope this helps someone facing a similar issue.

for MySQL on ARM (M3) use biarms/mysql:5.7

bokjo avatar Mar 18 '25 09:03 bokjo