Skip to content

fromDockerfile treats dockerFileName argument as folder #1028

@ViggoV

Description

@ViggoV

Expected Behaviour
Given the following

const container = await GenericContainer.fromDockerfile('.', 'build/next.Dockerfile').build()

I expect the output to be roughly equivalent to docker build -f build/next.Dockerfile ., ie. build from the next.Dockerfile file located in the build/ folder with the docker context "."

Actual Behaviour

The command fails because the second argument is considered a folder and /Dockerfile is appended. This ultimately results in the error:

Error: ENOTDIR: not a directory, open '/path/to/project/build/next.Dockerfile/Dockerfile'

Testcontainer Logs
...

Steps to Reproduce

  1. In this environment...
  • Any project with custom named Dockerfiles in a subfolder in relation to the context
  1. With this config...
  • Any
  1. Run '...'
  • const container = await GenericContainer.fromDockerfile('.', 'build/next.Dockerfile').build()
  1. See error...
  • Error: ENOTDIR: not a directory, open '/path/to/project/build/next.Dockerfile/Dockerfile'
    

Environment Information

  • Operating System: MacOS 15.5
  • Docker Version: 28.1.1, build 4eba377
  • Node version: v24.0.1
  • Testcontainers version: 11.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions