Reputation: 41
i will docker my app js. I run the order docker-compose up. But i have error : app | /bin/sh: 1: [: “npm”,: unexpected operator.
Dockerfile
FROM node:latest
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
EXPOSE 3000
RUN ["npm", "start" ]
docker-compose.yml
version: "2"
services:
app:
container_name: app
restart: always
build: .
ports:
- "3000:3000"
links:
- mongo
mongo:
container_name: mongo
image: mongo
volumes:
- ./data:/data/db
ports:
- "27017:27017"
Upvotes: 2
Views: 1158
Reputation: 3733
Double-check your Dockerfile.
"npm"
is different from “npm”
, notice the double quote "
and “
. You should
always use "
(input from your keyboard) rather than “
then run the following command:
docker-compose up --build
Upvotes: 8
Reputation: 12089
You could use the CMD
instruction instead of RUN
.
Change this line:
RUN ["npm", "start"]
...to this:
CMD ["npm", "start"]
The CMD
instruction is triggered when your container starts.
Docs here: https://docs.docker.com/engine/reference/builder/#cmd
I hope this helps.
Upvotes: 0