Reputation: 271
I am trying to build a dockerfile in which i am just starting a http-server. My dockerfile is:
FROM ubuntu
RUN apt-get update
RUN apt-get install -y nodejs && apt-get install -y npm
COPY testing /testing
RUN cd testing
RUN npm install
ENTRYPOINT npm start
Here testing is the project directory which consist of an index.html
file and package.json
.
My package.json is:
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "http-server -a 0.0.0.0 -p 5500"
},
"author": "",
"license": "ISC",
"dependencies": {
"concurrently": "^5.0.2",
"http-server": "^0.12.1"
}
}
In my local machine the server is working properly. I think the cd testing
command isn't appropriate and npm install
is not taking the package.json
file.
The docker image is formed under the Image ID - 6260786586cc
and the error while running an image through command is:
Upvotes: 1
Views: 12229
Reputation: 11193
Use WORKDIR
instruction instead of cd
.
WORKDIR testing
Each instruction in Dockerfile is executed in a separate container during build. So running cd
to change directory during build doesn't work.
Upvotes: 5