docker - 运行`node` docker容器时如何更改目录?
问题描述
我yarn
在节点 docker 容器中运行一个命令,我想更改 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 映像的情况下更改工作目录?
解决方案
使用--workdir
or-w
而不是尝试cd
:
docker run -v $(pwd)/$BUILDDIR:/outputs -it --rm -w /outputs node:12.16.2-alpine3.11 yarn install --only=production --pure-lockfile
推荐阅读
- c# - Office365 REST API 查询添加超链接到列表?ClientServiceException 无法反序列化 Microsoft.SharePoint.SPFieldUrlValue 类型的数据
- javascript - PWA - 强制横向定位不起作用
- flutter - 根据数据库值设置 SwitchTile 切换
- r - 将嵌套列表转换为数据框
- arrays - 对 swift 中的代码感到困惑?#array #matrix
- javascript - 您如何在 mongodb 中为特定用户保存某些项目?
- svg - 将带有内联 PlantUml 的降价文件导出为单个 SVG 文件
- sql - 如何在 postgres 的文本列上添加唯一约束(忽略特殊字符)?
- jekyll - 无法通过 jekyll-assets 或 jekyll-minifier 缩小 Jekyll javascript
- python - 编辑元组中的第二项