I want to use Docker to create development environments for a simple node.js project. I'd like to install my project's dependencies (they are all npm packages) inside the docker container (so they won't touch my host) and still mount my code using a volume. So, the container should be able
to find the node_modules
folder at the path where I mount the volume, but I should not see it from the host.
This is my Dockerfile:
FROM node:6
RUN mkdir /code
COPY package.json /code/package.json
WORKDIR /code
RUN npm install
This is how I run it:
docker build --tag my-dev-env .
docker run --rm --interactive --tty --volume $(pwd):/code my-dev-env npm test
And this is my package.json:
{
"private": true,
"name": "my-project",
"version": "0.0.0",
"description": "My project",
"scripts": {
"test": "jasmine"
},
"devDependencies": {
"jasmine": "2.4"
},
"license": "MIT"
}
It fails because it can't find jasmine
, so it's not really installing it:
> jasmine
sh: 1: jasmine: not found
Can what I want be accomplished with Docker? An alternative would be to install the packages globally. I also tried npm install -g
to no avail.
I'm on Debian with Docker version 1.12.1, build 23cf638.