Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...