为Ruby On Rails环境(从Dockerfile)创buildDocker镜像时出错
我想这是一个环境问题。 当我手动(没有Dockerfile)它的工作。
这是我的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
比我build立:
sudo docker build -t="james/rails" .
我得到这个错误:
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
尝试RUN /bin/bash -l -c "gem install rails -v 4.1.5"
而不是你在那里的那一行。 这会改变什么吗?
在Alex Lynham的帮助下,这里有一个可用的Dockerfile:
FROM ubuntu:14.04 RUN apt-get update 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 /bin/bash -l -c "rvm autolibs enable" RUN /bin/bash -l -c "rvm install 2.1.2" # install Rails RUN echo "gem: --no-rdoc --no-ri" >> ~/.gemrc RUN /bin/bash -l -c "gem install rails -v 4.1.5" # install nodeJS RUN sudo apt-get install nodejs --assume-yes EXPOSE 3000
你需要安装rubygems才能使用它。
RUN apt-get install rubygems
另请参阅: 我可以在Ubuntu上安装apt-get gem吗?