apocas / dockerode-compose

docker-compose in Node.js using dockerode
Apache License 2.0
141 stars 30 forks source link

"No command specified" error upon running .up() #5

Closed IvanPLoza closed 2 years ago

IvanPLoza commented 3 years ago

Hi, first of all I want to say thanks for creating this awesome tool for dockerode which I think a lot of people will love!

I am having an issue with using dockerode-compose up() promise. Basically when creating the docker-compose instance seems to work fine but using .up() method causes promise rejection.

Upon doing. this:

    var composer = new DockerodeCompose(docker, './docker-compose.yml', req.body.name);
    (async () => {
        console.log(composer.file, composer.projectName)
        composer.up().catch(err => console.log("ERRROR", err))
    })();

I would guess the docker api returns this from socket:

Error: (HTTP code 400) unexpected - No command specified 
    at /Users/ivan-pavao-lozancic/Desktop/git-repo/fuel-instance-creator/ic-backend/node_modules/docker-modem/lib/modem.js:315:17
    at getCause (/Users/ivan-pavao-lozancic/Desktop/git-repo/fuel-instance-creator/ic-backend/node_modules/docker-modem/lib/modem.js:345:7)
    at Modem.buildPayload (/Users/ivan-pavao-lozancic/Desktop/git-repo/fuel-instance-creator/ic-backend/node_modules/docker-modem/lib/modem.js:314:5)
    at IncomingMessage.<anonymous> (/Users/ivan-pavao-lozancic/Desktop/git-repo/fuel-instance-creator/ic-backend/node_modules/docker-modem/lib/modem.js:286:14)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  reason: undefined,
  statusCode: 400,
  json: { message: 'No command specified' }
}

Please keep in mind the docker-compose.yml file is present and working when executing from shell and project name also. I am really clueless about how to solve this. Please let me know if you need more details :)

Once again thank you so much for your commitment and great work! 😄

apocas commented 3 years ago

Strange the fact that the error does not mention dockerode. It should have a call there, without that it's hard to debug remotely.

Can you post a .yml (without critical information) that behaves the same?

IvanPLoza commented 3 years ago

Sure thing, I used this for R&D so I can share most of it. Basically I put together three services that are controlled by one project (docker-compose file which contains three services) and those are extended in another docker-compose which this dockerode-compose is trying to make up on the services.

So here is the concept: We have a docker container running nodejs and using dockerode. I have mounted docker socket of the host that is running these containers to the nodejs container itself and dockerode works fine (eg. I can list all containers, start stop and etc. tested). That nodejs app should use dockerode-compose to start multiple instances of another example project that holds three containers (frontend, backend, database). The flow works fine when nodejs app is started on host machine tries to do this via https://www.npmjs.com/package/docker-compose but to achieve this inside the docker container I need to use docker socket which dockerode can work with easily.

Here is the main docker-compose file:

version: '3'
services:

    db:
        extends:
            file: ./2-nodejs-projects/docker-compose.yml
            service: db
        volumes:
            - db_data:/var/lib/mysql
        expose:
            - "3306"

    app1:
        extends:
            file: ./2-nodejs-projects/docker-compose.yml
            service: app1
        depends_on: 
            - db
        ports:
            - "5001-5005:5000"

    app2:
        extends:
            file: ./2-nodejs-projects/docker-compose.yml
            service: app2
        ports:
            - "5006-5010:5000"

volumes:
    db_data: {}

And here is the other one:

version: '3'
services:

  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: fuelDatabase
      MYSQL_USER: fuel
      MYSQL_PASSWORD: fuelDatabase2021

  app1:
    build: ./simple-node-app
    environment:
      DB_HOST: db
      DB_DATABASE: fuelDatabase
      DB_USER: root
      DB_PASSWORD: root

  app2:
    build: ./simple-node-app-1235

volumes:
  db_data: {}
nunokisc commented 3 years ago

In your docker compose files i see that you are using two specs not implemented yet. I mean, at this time only one remains to be implemented :) Soon you can deploy that easily with dockerode-compose :D

IvanPLoza commented 3 years ago

@nunokisc Hi, thanks for the reply but I don't think that extends specification makes this issue. I tried to start this using only one docker-compose.yml file without extends specification and it also gives "No command specified". Could it be some other specification I use for these three services that creates this problem? Glad to help if you need more details, thanks :)

nunokisc commented 3 years ago

@IvanPLoza Yes the other one, of the two that i mentioned is the build spec. So, when build spec is implemented your compose files will work without any problems.

IvanPLoza commented 3 years ago

Great! Thanks so much 🙂

apocas commented 3 years ago

Just published a new version. You should be able to run your compose files now :)

PS: give us some feedback