首先,
在书籍源代码中:
[Air@host sinatra]$ cat dockerbook-code/code/5/sinatra/webapp/Dockerfile
FROM ubuntu:16.04
LABEL maintainer="james@example.com"
ENV REFRESHED_AT 2014-06-01
RUN apt-get -qq update && apt-get -qq install ruby ruby-dev build-essential redis-tools
RUN gem install --no-rdoc --no-ri sinatra json redis
RUN mkdir -p /opt/webapp
EXPOSE 4567
CMD [ "/opt/webapp/bin/webapp" ]
该Dockerfile
使用 apt-get
在安装 ruby
时默认安装了 ruby 1.8.7
,在安装sinatra
时就会报错:
rack requires Ruby version >= 2.2.2.
于是,需要 重新安装 高版本的 ruby;
通过下载源码进行安装的 Dockerfile :
FROM ubuntu:14.04
MAINTAINER Aemonair "v.aemonair@gmail.com"
ENV REFESHED_AT 20180929
# RUN alias /bin/sh /bin/bash
RUN apt-get -yqq update && apt-get -yqq install wget curl gnupg2 libcurl3 build-essential redis-tools
RUN apt-get install -y --force-yes zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt-dev
RUN cd /tmp
RUN wget http://ftp.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.gz
RUN tar -xvzf ruby-2.5.0.tar.gz
RUN cd ruby-2.5.0/ && ./configure --prefix=/usr/local; make; make install
RUN ruby -v
RUN ln -s /usr/local/bin/ruby /usr/bin/ruby
RUN gem install --no-rdoc --no-ri sinatra json redis
RUN mkdir -p /opt/webapp
EXPOSE 4567
CMD [ "/opt/webapp/bin/webapp" ]
通过下载了ruby2.5的源码 ./configure 、 make、 make install
编译安装后,
不再报错;