<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>ithelloworld</title>
    <link>https://ruby-china.org/ithelloworld</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>使用 Docker 部署应用如何执行脚本文件？</title>
      <description>&lt;p&gt;我想用 Docker 部署一个 Rails 应用。&lt;/p&gt;

&lt;p&gt;Dockerfile 的内容如下：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM ruby:2.2.2

ENV APP_HOME /myapp
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

ADD Gemfile $APP_HOME/Gemfile
ADD Gemfile.lock $APP_HOME/Gemfile.lock
ADD init.sh $APP_HOME/

RUN export LANG=C.UTF-8 &amp;amp;&amp;amp; bundle install

ADD . $APP_HOME

CMD ["sh", "init.sh"]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;init.sh 程序执行脚本内容如下：&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
bundle &lt;span class="nb"&gt;exec &lt;/span&gt;rake db:setup
bundle &lt;span class="nb"&gt;exec &lt;/span&gt;rake db:seed_fu
bundle &lt;span class="nb"&gt;exec &lt;/span&gt;sidekiq &lt;span class="nt"&gt;-C&lt;/span&gt; config/sidekiq.yml
bundle &lt;span class="nb"&gt;exec &lt;/span&gt;rails server &lt;span class="nt"&gt;-b&lt;/span&gt; 0.0.0.0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;当我编译完这个程序镜像：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t myapp .
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;运行它时：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --name web -d -p 3000:3000 myapp
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;从日志中看到：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker logs web
init.sh: 2: init.sh: bundle: not found
init.sh: 3: init.sh: bundle: not found
init.sh: 4: init.sh: bundle: not found
init.sh: 5: init.sh: bundle: not found
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;是执行 &lt;code&gt;bundle&lt;/code&gt; 的路径问题，怎么指定正确的路径呢？&lt;/p&gt;</description>
      <author>ithelloworld</author>
      <pubDate>Mon, 16 Nov 2015 11:47:05 +0800</pubDate>
      <link>https://ruby-china.org/topics/28071</link>
      <guid>https://ruby-china.org/topics/28071</guid>
    </item>
  </channel>
</rss>
