1

From this documentation, it seems like that I can execute a single command from a service like this:

docker-compose run SERVICE CMD

But when I run

docker-compose up pwa npm test

I get the error

ERROR: No such service: npm

From my configurations, it will execute npm start, but I'd like to know how to execute other commands.

Files

Dockerfile:

From node:8
WORKDIR /app
copy package.json /app/
RUN npm install --quiet
CMD npm start

docker-compose.yml:

version: '3'
services:
  pwa:
    build: .
    ports:
      - '3000:3000'
    volumes:
      - ./src:/app/src
      - ./public:/app/public

Versions

Docker version: 17.03

Docker compose version: 1.11.2

1 Answer 1

1

As docs say, the command is docker-compose run, not docker-compose up. The later expects all service names.

Do as this:

docker-compose run pwa npm test
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.