Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

node.js - How to copy back to host package-lock.json/yarn.lock after install dependencies inside docker container?

I'm using Docker containers to run my CRA application. I use 2 different DockerFile, one for running CRA in development and one to generate the build. During the step of installing dependencies:

FROM node:15.5.0-alpine3.10

USER node

RUN mkdir /home/node/code
WORKDIR /home/node/code

COPY package.json yarn.lock ./
RUN yarn

ENV PATH /home/node/code/node_modules/.bin:$PATH

CMD yarn start

I need to copy my updated yarn.lock file (or package-lock.json file is using NPM) back to host after the container generate the new version of the file.

I had search the solution everywhere, but I didn't find anything to resolve this problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

docker cp, for example docker cp [running container id]:/home/node/code/yarn.lock yarn.lock. You can also use volumes rather than copying things in and out.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...