我正在运行yo在 Docker 容器和我的 Dockerfile 中,我有命令 RUN echo no | yo doctor
.当 yo 第一次运行时,它会要求回答:
==================================================================== We're constantly looking for ways to make yo better! May we anonymously report usage statistics to improve the tool over time? More info: https://github.com/yeoman/insight & http://yeoman.io ==================================================================== (Y/n)
每次,我创建一个新容器,哟又问我同样的问题。
由于每个容器都是使用相同的镜像构建的,并且我正在运行
echo no | yo doctor
在我的 Dockerfile 中,它不应该阻止你再次问这个问题吗?
最佳答案
每当我看到 RUN 使用管道时,我都会在子 shell (sh -c
) 中尝试该命令
RUN sh -c 'echo no | yo doctor'
如果它不起作用,另一种解决方法是将该命令包含在脚本中,
COPY
脚本和RUN
它。
关于docker - Dockerfile 中的 RUN 命令不会在容器之间持续存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37891878/