Docker cli:带引号的docker run命令
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker cli:带引号的docker run命令相关的知识,希望对你有一定的参考价值。
我正在尝试使用以下Docker cli命令运行execute jest -t
变体:
docker run -it node-jest npx jest -t "This string matches exactly one test"
如果我要在本地运行npx jest -t "This string matches exactly one test"
,则不会做同样的事情。
似乎双引号被剥夺/忽略,只有This
传递给jest -t
。看来This string matches exactly one test
正在空格中分离,并被视为单个参数。有人可以解释为什么会这样,以及如何正确地(希望以可读/理智的方式)将"This string matches exactly one test"
传递给docker run
吗?
答案
[您没有提到该错误,并且引号似乎还不错,并且可以使用shell运行或运行容器,但是我的假设是您未在Dockerfile中设置WORKING
目录,或者Dockerfile出了点问题
这里是从jest docker imag e和testing code中提取的工作示例。
docker run -ti adiii717/jest sh -c 'npx jest -t "it should filter by a search term (link)"'
输出:
对所有测试套件进行匹配“其应按搜索词(链接)进行过滤”的测试。
-----------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
-----------------|----------|----------|----------|----------|-------------------|
All files | 12.5 | 0 | 0 | 16.67 | |
filterByTerm.js | 12.5 | 0 | 0 | 16.67 | 2,3,4,5,6 |
-----------------|----------|----------|----------|----------|-------------------|
Test Suites: 1 skipped, 0 of 1 total
Tests: 3 skipped, 3 total
Snapshots: 0 total
Time: 1.109s
Ran all test suites with tests matching "it should filter by a search term (link)".
这里是Dockerfile
FROM node:alpine
RUN apk add --no-cache git
RUN npm install jest npx -g
WORKDIR /app
RUN git clone https://github.com/valentinogagliardi/getting-started-with-jest.git /app
RUN npm install
以上是关于Docker cli:带引号的docker run命令的主要内容,如果未能解决你的问题,请参考以下文章
五分钟带你玩转docker可视化界面portainer极简安装,楼主亲测