PDMLab / docker-compose

Manage Docker-Compose via Node.js
https://pdmlab.github.io/docker-compose/
MIT License
196 stars 78 forks source link

ps doesn't output all services -> offset of 1 service #251

Open FredPi17 opened 1 year ago

FredPi17 commented 1 year ago

Hello everyone !

I'm having an issue with ps command. Find below the test code I execute to ps services of a stack of services:

const compose = require('docker-compose')

compose.ps({
    cwd: '~/personnal-repo/project/user_id/testkikou', log: false
  })
  .then((data) => {
    console.log(data)
    console.log(data.data)
  })
  .catch((err) => {
    console.log(err)
})

And here the output in my console:

{
  exitCode: 0,
  err: '',
  out: 'NAME                IMAGE                                 COMMAND                  SERVICE             CREATED             STATUS                          PORTS\n' +
    'jupyter-testkikou   jupyter/datascience-notebook:latest   "tini -g -- start-no…"   jupyter-testkikou   30 seconds ago      Up 29 seconds (healthy)         8888/tcp\n' +
    'nginx-testkikou     testkikou-nginx-testkikou             "/docker-entrypoint.…"   nginx-testkikou     About an hour ago   Restarting (1) 49 seconds ago   \n' +
    'vscode-testkikou    lscr.io/linuxserver/code-server       "/init"                  vscode-testkikou    32 minutes ago      Up 32 minutes                   8443/tcp\n',
  data: { services: [ [Object], [Object] ] }
}
{
  services: [
    {
      name: 'nginx-testkikou',
      command: 'testkikou-nginx-testkikou',
      state: '"/docker-entrypoint.…"',
      ports: [Array]
    },
    {
      name: 'vscode-testkikou',
      command: 'lscr.io/linuxserver/code-server',
      state: '"/init"',
      ports: [Array]
    }
  ]
} 

As you can see, in the first part of the log we see three services (those are running), and in the second part (second console.log) we see the services object returned by the package. If I stop one service from the stack, it shows 1 service in the service object.

I don't know if the issue comes from me with my. bad usage or from a regression of the package. Your help is appreciated !

Thanks in advance 👍

AlexZeitler commented 1 year ago

@FredPi17 which version of the docker-compose npm package and which version of the docker-compose CLI do you use? From your require statement I can guess you're using v1 of the CLI, right?

Please post the output of docker-compose --version