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

Add `withPlatform()` method to `GenericContainer`

Open timbrinded opened this issue 1 year ago • 0 comments

Expected Behaviour I want to be able to specify platform so I can run linux/amd64 images on apple mac without issues.

Most images have both amd64 & arm64 flavours, but i'd like to be able to specify platform for the times where only x86 is available.

Actual Behaviour I get errors because an image can't be pulled for the current host platform architecture. This is analagous with running docker pull moonsonglabs/storage-hub on an Apple Silicon device.

Testcontainer Logs

/Users/timbo/workspace/personal/test-repro-testcontainers/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:343
      var msg = new Error(
                ^

Error: (HTTP code 404) unexpected - no match for platform in manifest: not found
    at /Users/timbo/workspace/personal/test-repro-testcontainers/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:343:17
    at IncomingMessage.<anonymous> (/Users/timbo/workspace/personal/test-repro-testcontainers/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:370:9)
    at IncomingMessage.emit (node:events:531:35)
    at IncomingMessage.emit (node:domain:488:12)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  reason: undefined,
  statusCode: 404,
  json: null
}

Steps to Reproduce

Have a go with the snippet on an apple mac:

import { GenericContainer } from "testcontainers";

async function main() { const container =await  new GenericContainer("moonsonglabs/storage-hub")
.start();
console.log("Started")

await new Promise(resolve=> setTimeout(resolve, 60000));
container.stop();
}

main()

[!CAUTION] Error thrown: Error: (HTTP code 404) unexpected - no match for platform in manifest: not found

[!NOTE]
I have tried to workaround this with DOCKER_DEFAULT_PLATFORM but this doesn't make a difference.

Environment Information

  • Operating System: macOS 14.4.1
  • Docker Version: 26.1.1
  • Node version: 21.x
  • Testcontainers version: 10.9.0

timbrinded avatar Jun 06 '24 10:06 timbrinded