Reputation: 3402
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.
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
Docker version: 17.03
Docker compose version: 1.11.2
Upvotes: 1
Views: 1295
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