我在节点docker容器内运行一个yarn
命令,我想更改docker命令上的目录。我正在使用的当前命令是:
docker run -v $(pwd)/$BUILDDIR:/outputs -it --rm node:12.16.2-alpine3.11 cd /outputs;yarn install --only=production --pure-lockfile
我得到了这个输出:
sh: can't open 'cd': No such file or directory
yarn install v1.22.4
[1/4] ? Resolving packages...
success Already up-to-date.
✨ Done in 0.13s.
似乎它试图将cd
作为脚本文件运行。如何在不更新docker映像的情况下更改工作目录?
答案 0 :(得分:1)
使用--workdir
或-w
而不是尝试cd
:
docker run -v $(pwd)/$BUILDDIR:/outputs -it --rm -w /outputs node:12.16.2-alpine3.11 yarn install --only=production --pure-lockfile