Reputation: 141
I am trying to start multiple services with docker-compose but I get
npm ERR! missing script: start
in my console when I run the docker-compose up command
Note I am able to start the each of the services individually with docker run command.
Below is a copy of my docker-compose.yml file
version: '3.4'
services:
clientservice:
image: clientapplication
build:
context: .
dockerfile: ./client/Dockerfile
environment:
NODE_ENV: production
ports:
- "3000:3000"
networks:
- blogmicroservice
commentservice:
image: commentsservice
build:
context: .
dockerfile: ./comments/Dockerfile
environment:
NODE_ENV: production
ports:
- "4001:4001"
networks:
- blogmicroservice
moderationservice:
image: moderationservice
build:
context: .
dockerfile: ./moderation/Dockerfile
environment:
NODE_ENV: production
ports:
- "4003:4003"
networks:
- blogmicroservice
postservice:
image: postservice
build:
context: .
dockerfile: ./posts/Dockerfile
environment:
NODE_ENV: production
ports:
- "4000:4000"
networks:
- blogmicroservice
eventbusservice:
image: eventbus
build:
context: .
dockerfile: ./event-bus/Dockerfile
environment:
NODE_ENV: production
ports:
- "4005:4005"
networks:
- blogmicroservice
queryservice:
image: queryservice
build:
context: .
dockerfile: ./query/Dockerfile
environment:
NODE_ENV: production
ports:
- "4002:4002"
networks:
- blogmicroservice
networks:
blogmicroservice:
driver: bridge
An example of the docker file for individual service
FROM node:12.18-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "./"]
RUN npm install --production --silent
COPY . .
EXPOSE 4002
CMD ["npm", "start"]
Upvotes: 0
Views: 769
Reputation: 371
In the docker-compose file, all services are using the same context
build:
context: .
Which means all files will be copied to docker daemon at build time. This is very unlikely to be the case because different apps cannot have the same code base. If each image can be properly run, then the problem may not lie in Dockerfile. You can change context to proper directory:
build:
context: ./your-server
Note that when the value in context:
supplied is a relative path, it is interpreted as relative to the location of the Compose file. This directory is also the build context that is sent to the Docker daemon.. So, you may not even need to specify the Dockerfile location.
Upvotes: 2
Reputation: 141
i resolved this ..the context in docker-compose.yml was out of place updated it to this and it startsup fine now
version: '3.4'
services:
clientservice:
image: clientapplication
build:
context: ./client
dockerfile: ./Dockerfile
environment:
NODE_ENV: production
ports:
- "3000:3000"
networks:
- blogmicroservice
commentservice:
image: commentsservice
build:
context: ./comments
dockerfile: ./Dockerfile
environment:
NODE_ENV: production
ports:
- "4001:4001"
networks:
- blogmicroservice
moderationservice:
image: moderationservice
build:
context: ./moderation
dockerfile: ./Dockerfile
environment:
NODE_ENV: production
ports:
- "4003:4003"
networks:
- blogmicroservice
postservice:
image: postservice
build:
context: ./posts
dockerfile: ./Dockerfile
environment:
NODE_ENV: production
ports:
- "4000:4000"
networks:
- blogmicroservice
eventbusservice:
image: eventbus
build:
context: ./event-bus
dockerfile: ./Dockerfile
environment:
NODE_ENV: production
ports:
- "4005:4005"
networks:
- blogmicroservice
queryservice:
image: queryservice
build:
context: ./query
dockerfile: ./Dockerfile
environment:
NODE_ENV: production
ports:
- "4002:4002"
networks:
- blogmicroservice
networks:
blogmicroservice:
driver: bridge
Upvotes: 0