How to pass a file to docker container and get output from the container into node app using dockerode

115 views Asked by At

I am writing a simple script in nodejs that will pass a file to a docker container, the container will process the file and generate a json output. I am using Dockerode to connect to the docker container. the input file is in the same folder as the script.

Here is the code I have written so far.

const docker = new Docker()
const container = await docker.createContainer({
Image:"imageId",
AttachStdin: true,
AttachStdout: true,
AttachStderr: true,
Tty: true,
Cmd: ['bash']
})

I am unsure how to pass the file as a stream to this container i have created and then get the output stream from the docker container.

0

There are 0 answers