Dockerode: Custom dockerfile path?

Created on 9 Nov 2017  路  3Comments  路  Source: apocas/dockerode

Hello I attempted to build a subdirectory using the directory's dockerfile by doing

docker.buildImage(
  tar.pack(resolve('./', cwd)),
  {
    f: resolve('../docker-images/nodejs/Dockerfile'),
    t: settings.name
  },
  (err, output) => {
    output.pipe(process.stdout)
  }
)

However it seems to ignore the f property thus reporting error:

Error: (HTTP code 500) server error - Cannot locate specified Dockerfile: Dockerfile

Or do I have to include the Dockerfile in the tar pack already rather than setting a custom dockerfile in the options?

Most helpful comment

3 years after....thanks @Seikho !
Here is a quick visual example for future visitors. 馃コ

await dockerode.buildImage({
    context: __dirname,
    src: ['path/to/Dockerfile', 'dependency1', 'dependency2', '...']
}, {
    t: imageName + ':' + version,
    dockerfile: 'path/to/Dockerfile'
});

All 3 comments

Looking at my code that uses this, I include the Dockerfile in the tarball and provide the path by adding a dockerfile property on the options object.
See here for an example

Thanks that a way to do it :+1:

3 years after....thanks @Seikho !
Here is a quick visual example for future visitors. 馃コ

await dockerode.buildImage({
    context: __dirname,
    src: ['path/to/Dockerfile', 'dependency1', 'dependency2', '...']
}, {
    t: imageName + ':' + version,
    dockerfile: 'path/to/Dockerfile'
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

florentvaldelievre picture florentvaldelievre  路  4Comments

AlexanderCollins picture AlexanderCollins  路  5Comments

yamii picture yamii  路  5Comments

controversial picture controversial  路  3Comments

hackhat picture hackhat  路  4Comments