0

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.

pranit
  • 128
  • 1
  • 1
  • 8
  • Using Docker here makes this task significantly more complicated. Can you run the other process as an ordinary subprocess, without Docker? Or can you put an HTTP or other network interface on the other process, and make an HTTP POST request to it, without doing anything Docker-specific? (In general, a process that reads and writes local files as its main form of interaction doesn't match up well with Docker's filesystem isolation features.) – David Maze Dec 15 '22 at 11:33
  • We already have docker images that do a bunch of processing, so unfortunately i have to access the containers. My understanding was TTY was responsible for piping the input and output to and from the container. @DavidMaze – pranit Dec 15 '22 at 11:37

0 Answers0