提问者:小点点

无法从Dockerfile运行源命令


这是Dockerfile中的脚本。当我直接进入docker并手动运行命令时,它工作得很好,但为什么不从Dockerfile开始呢。

Dockerfile:

FROM ubuntu:16.04
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get update
RUN apt-get install -y build-essential libssl-dev
RUN apt-get install -y curl git sudo

RUN curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install_nvm.sh
RUN /bin/sh install_nvm.sh
RUN source ~/.profile

错误:

mesg:ttyname失败:设备的ioctl不正确

我已经尝试了一些解决方案,发现像运行它为RUN /bin/sh-c"Source~/. file",但没有解决这个问题。


共2个答案

匿名用户

尝试用下面的命令替换您的命令<代码>运行/bin/bash-c“source~/.profile”

匿名用户

这与以下问题非常相似:如何解决Vagrant中的“ttyname失败:设备的ioctl不适当”?

~/。配置文件有一行:

mesg n || true

这是不相容的。为了解决此问题,请以tty是否可用为条件(credit Gogowitch):

RUN sed -i ~/.profile -e 's/mesg n || true/tty -s \&\& mesg n/g'

此sed命令将mesg n | | true(尝试,如果失败则忽略)替换为tty-s