dockerode
dockerode copied to clipboard
Remove control characters from UNIX Domain Socket
Hello, i have a problem with docker exec command output, when i try to run:
// modem.js
var Docker = require("dockerode");
const path = require("path");
var docker = new Docker({ socketPath: "/var/run/docker.sock" });
docker.createContainer(
{
Tty: false,
Image: "ubuntu",
Cmd: ["/bin/bash"],
OpenStdin: true,
Volumes: {
"/tmp": {},
},
HostConfig: {
Binds: [`${path.resolve("./tmp")}:/tmp`],
},
},
function (err, container) {
container.start(function (err) {
container.exec(
{ Cmd: ["cat", "./tmp/schema.json"], AttachStdin: true, AttachStdout: true },
function (err, exec) {
exec.start({ hijack: true, stdin: true }, function (err, stream) {
let chunks = [];
stream.on("data", (chunk) => {
chunks.push(chunk.toString("utf-8"))
});
stream.on("error", (err) => reject(err));
stream.on("end", () => {
// console.log(JSON.parse(chunks.join(""))) parsing error
console.log(chunks.join(""))
});
});
}
);
});
}
);
Where schema.json
is a large file (21MB)
but when i parse with json parse the result of this promise i receive this control characters:

is possible to remove this control characters from the chunks?
i run node modem.js > logs.json
for replicate the problem