Con*_*ell 4 terminal node.js npm docker
我试图包含 npm 的终端进度条之一,以更好地可视化一个漫长的过程的进展情况。当我从标准的“node index.js”运行它时,它会顺利运行,但是当从简单的 docker 映像运行时,没有任何内容发布到终端。我的index.js是这样的:
const _cliProgress = require('cli-progress');
// create a new progress bar instance and use shades_classic theme
const bar1 = new _cliProgress.Bar({}, _cliProgress.Presets.shades_classic);
// start the progress bar with a total value of 200 and start value of 0
bar1.start(200, 0);
// update the current value in your application..
bar1.update(100);
// stop the progress bar
bar1.stop();
Run Code Online (Sandbox Code Playgroud)
这是我的 docker 文件:
FROM node:latest
#create work directory
RUN mkdir -p /src
#establish the app folder as the work directory
WORKDIR /src
COPY package.json /src
COPY package-lock.json /src
RUN npm i
COPY . /src
CMD [ "node", "index.js" ]
Run Code Online (Sandbox Code Playgroud)
终端不显示这些包中的任何内容,但显示正常的 console.logs。我尝试使用的其他包也存在此问题。
任何有关为什么这与预期结果不同的信息将不胜感激。谢谢。
你必须运行带有--tty , -t标志的 docker,这将分配一个伪 TTY
docker run -t --rm test
Run Code Online (Sandbox Code Playgroud)
您可以检查以下问题以获得有关该标志的更详细解释:
将 tty/std-in-out 附加到 dockers 或 lxc 意味着什么?
| 归档时间: |
|
| 查看次数: |
3109 次 |
| 最近记录: |