Nelson Yeung
Nelson Yeung

Reputation: 3402

docker compose run with command error

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

Upvotes: 1

Views: 1295

Answers (1)

Robert
Robert

Reputation: 36873

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

Upvotes: 1

Related Questions