我正在尝试创建一个Dockerfile来部署Rails应用程序,但我的问题是如果我使用Dockerfile,Ruby将无法安装,因为它会显示缺少/dev/fd。在普通机器上,我只需要输入命令ln -sf /proc/self/fd /dev/fd
,就能解决所有问题。然而,当我将该命令放入我的Dockerfile中时,它不会链接到/dev/fd。以下是我的Dockerfile:
# Select ubuntu as the base image
FROM ubuntu
# Install nginx, nodejs and curl
RUN apt-get update -q
RUN apt-get install -qy nginx
RUN apt-get install -qy curl
RUN apt-get install -qy nodejs
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# Install rvm, ruby, bundler
RUN curl -sSL https://get.rvm.io | bash -s stable
RUN ln -sf /proc/self/fd /dev/fd
RUN echo "source /usr/local/rvm/scripts/rvm" >> /etc/bash.bashrc
RUN /bin/bash -l -c "rvm requirements"
RUN /bin/bash -l -c "rvm install 2.1.2"
我会遇到类似于"/dev/fd: 缺少文件或文件夹"之类的错误。如果我省略最后一行,所有内容都能够成功构建,但是当我登录到刚刚构建的图像并进入/dev/fd目录时,会显示"没有这样的文件或目录"。为什么它可以成功构建但是不会链接我要求的文件呢?