Vivek Kodira Vivek Kodira - 10 days ago 10
Node.js Question

Docker-compose fails with error "No command specified"

Starting the container with the run command

docker run -it -d -p 8888:8888 install_advisor node src/server


works as expected. But trying to bring it up using docker-compose results in the error:


"ERROR: for advisor Cannot create container for service advisor: No
command specified"


What am I doing wrong?

Contents of docker-compose.yml

advisor:
build:
context: .
dockerfile: DockerfileAdvisor
ports:
- "8888:8888"
restart: always
privileged: true


Contents of DockerfileAdvisor

FROM XYZ
ENTRYPOINT [ "node", "src/server" ]

Answer

I'm a bit surprised that your solution doesn't work as it is. But you can probably fix it in several ways. Here some suggestions:

1) Change your DockerFileAdvisor file to

FROM XYZ
COMMAND [ "node", "src/server" ]

2) If DockerFileAdvisor really contains just the two rows that are shown in your question, you don't even need it. Just specify image: XYZ and command: [ "node", "src/server" ] in your docker-compose.yml:

advisor:
    image: XYZ
    ports:
      - "8888:8888"
    restart: always
    privileged: true
    command: [ "node", "src/server" ]

Maybe you'd like to take a look on Docker documentation how ENTRYPOINT and COMMAND directives play together. In short, with ENTRYPOINT you can make an image to look like an executable and use COMMAND to just pass parameters for it.

Comments