简体   繁体   中英

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" ]

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM