为Ruby On Rails环境(从Dockerfile)创建Docker映像时出错 [英] Error when creating a Docker image for Ruby On Rails environment (from a Dockerfile)

查看:289
本文介绍了为Ruby On Rails环境(从Dockerfile)创建Docker映像时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这是一个环境问题。
当我手动(没有Dockerfile)它是有效的。



这是我的Dockerfile:

  FROM ubuntu:14.04 
运行apt-get update
运行apt-get升级--assume-yes
运行apt-get install wget vim git - -assume-yes
#安装RVM
运行apt-get install build-essential curl --assume-yes
运行curl -L https://get.rvm.io | bash -s stable
RUN echo'source /etc/profile.d/rvm.sh'>> 〜/ .bashrc
RUN / usr / local / rvm / bin / rvm-shell -crvm要求
#install Ruby
RUN / usr / local / rvm / bin / rvm- shell -crvm autolibs启用
RUN / usr / local / rvm / bin / rvm-shell -crvm install 2.1.2
#install Rails
RUN echogem: --no-rdoc --no-ri>> 〜/ .gemrc
运行gem安装rails -v 4.1.5
#install nodeJS
运行sudo apt-get install nodejs --assume-yes
EXPOSE 3000

比我搭搭:

  sudo docker build -t =james / rails。 

我得到这个错误:

 步骤11:运行gem安装rails -v 4.1.5 
--->运行在44efc6b7c254
/ bin / sh:1:gem:not found
2014/09/04 18:33:52命令[/ bin / sh -c gem install rails -v 4.1.5]返回非零代码:127


解决方案

尝试 RUN / bin / bash -l -cgem install rails -v 4.1.5而不是你在那里的行。这会改变什么吗?


I guess it's a environment problem. When I do it manually (without a Dockerfile) it works.

Here's my Dockerfile:

FROM ubuntu:14.04
RUN apt-get update
RUN apt-get upgrade --assume-yes
RUN apt-get install wget vim git --assume-yes
# install RVM
RUN apt-get install build-essential curl --assume-yes
RUN curl -L https://get.rvm.io | bash -s stable
RUN echo 'source /etc/profile.d/rvm.sh' >> ~/.bashrc
RUN /usr/local/rvm/bin/rvm-shell -c "rvm requirements"
# install Ruby
RUN /usr/local/rvm/bin/rvm-shell -c "rvm autolibs enable"
RUN /usr/local/rvm/bin/rvm-shell -c "rvm install 2.1.2"
# install Rails
RUN echo "gem: --no-rdoc --no-ri" >> ~/.gemrc
RUN gem install rails -v 4.1.5
# install nodeJS
RUN sudo apt-get install nodejs --assume-yes
EXPOSE 3000

Than I build with:

sudo docker build -t="james/rails" .

I get that error:

Step 11 : RUN gem install rails -v 4.1.5
 ---> Running in 44efc6b7c254
/bin/sh: 1: gem: not found
2014/09/04 18:33:52 The command [/bin/sh -c gem install rails -v 4.1.5] returned a non-zero code: 127

解决方案

Try RUN /bin/bash -l -c "gem install rails -v 4.1.5" instead of the line you've got in there. Does that change anything?

这篇关于为Ruby On Rails环境(从Dockerfile)创建Docker映像时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆