Thursday, 4 May 2017

Store persistent data in docker container directory

I want to manually cache node_modules using Docker, something like this:

COPY . .  # copy everything (node_modules is gitignored though)
COPY package.json /tmp/test-deps
RUN (cd /tmp/test-deps && npm install --no-optional > /dev/null 2>&1)
RUN ln -s /tmp/test-deps/node_modules /root/cdt-tests/node_modules  

this works, but it appears to me that /tmp/test-deps/node_modules is re-created each time the container is built.

How can I create a persistent directory so that I don't have to re-install node_modules each time?



via Alexander Mills

No comments:

Post a Comment