我有一個定義Ruby on Rails堆棧的Dockerfile。當構建Dockerfile時linux source命令不工作
這裏是Dockerfile:
FROM ubuntu:14.04
MAINTAINER example <[email protected]>
# Update
RUN apt-get update
# Install Ruby and Rails dependencies
RUN apt-get install -y \
ruby \
ruby-dev \
build-essential \
libxml2-dev \
libxslt1-dev \
zlib1g-dev \
libsqlite3-dev \
nodejs \
curl
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
RUN curl -sSL https://get.rvm.io | bash -s stable --rails
RUN /bin/bash -c "source /usr/local/rvm/scripts/rvm"
# Install Rails
RUN gem install rails
# Create a new Rails app under /src/my-app
RUN mkdir -p /src/new-app
RUN rails new /src/new-app
WORKDIR /src/my-app
# Default command is to run a rails server on port 3000
CMD ["rails", "server", "--binding", "0.0.0.0", "--port" ,"3000"]
EXPOSE 3000
當我執行命令docker build -t anotherapp/my-rails-app .
我收到以下錯誤:
Removing intermediate container 3f8060cdc6f5
Step 8 : RUN gem install rails
---> Running in 8c1793414e63
ERROR: Error installing rails:
activesupport requires Ruby version >= 2.2.2.
The command '/bin/sh -c gem install rails' returned a non-zero code: 1
它看起來像命令source /usr/local/rvm/scripts/rvm
在生成過程中不能正常工作。
我不確定這是爲什麼發生。
該命令正在工作,但是當命令結束時,shell將退出並且所有內容都會再次消失。 – tkausl
你可能不應該使用rvm來安裝rails,但是如果你想鏈接所有'RUN's,因爲它們每個都創建一個新圖層,並且可能不知道你的bash採購 – bjhaid
你讀過這個答案了嗎?http: //stackoverflow.com/a/25685004/1981061? – Griffin