0

I am working on a Docker Swarm data visualization tool with a team. It works as follows:

Our backend is set up in a way that terminal commands can be executed from our code, where these terminal commands have been promisified and the result of this command should be a string of nodeIDs corresponding to the active nodes in my Docker Swarm. This data is then passed to another helper function, however, I am unable to move past the previously explained step due to an unexpected output from my promisified terminal command.

const getNodeIDs = () => {
  console.log('in nodeID helper function');
  return execProm("docker node ls --format '{{json .ID}}'").then(
    (rawNodeIDs) => {
      console.log('rawNodeIds: ', rawNodeIDs);
      const parsedNodeIDs = parseRawData(rawNodeIDs);
      console.log('parsedNodeIDs: ', parsedNodeIDs);
      return parsedNodeIDs;
    }
  );
};

My code fails on line 6 due to the fact that the data being passed to my parseRawData function is not what it is expected. The console log on line 5 above returns as follows:

{
   stdout: 'Saved file tree to doc-filelist.js\n' +
     'Copied JS to doc-script.js\n' +
     'Compiled CSS to doc-style.css\n',
   stderr: ''
 }

In addition to this being the wrong output, every time I invoke this command, a new file is created in my codebase labeled "docs" with the following three files inside: doc-filelist.js, doc-script.js, doc-style.css. I am working in a team of 4 other engineers, and I seem to be the only person experiencing this behavior. When I attempt to run the terminal command (featured on line 3 in the first block of code) directly in the terminal itself, I receive the expected output of

"odwch32vsynhxbc0ia2nwicag"

which is the nodeID of the single node currently in my Docker Swarm and what I should be receiving when invoking the terminal command from the code.

I've only been able to find one other stack overflow article dealing with the same issue in which that person was told to try running the terminal command

npm uninstall -g docker

which I have done, and this did not fix my issues. I've also looked into making edits to the Docker daemon itself, but am unsure that this is the real root of the issue. Since I am the only person on my team that seems to be encountering this bug, I have reason to believe that this error has something to do with my dev environment. My containers are running on Docker v4.15.0 and I am working on macOS on an M1 chip computer.

Thanks!

0 Answers0