2016-05-30 23 views
0

我試圖使用docker將現有的rails項目推送到docker容器。web_1 | /docker-entrypoint.sh:第99行:exec:bundle:未找到app_web_1用代碼127退出

我正在使用postgres數據庫。

當我做$> docker-compose up

我獲取日誌中的以下錯誤。

web_1 | /docker-entrypoint.sh: line 99: exec: bundle: not found 
app_web_1 exited with code 127 

-

# Dockerfile 
FROM ruby:2.2.0 
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs 
RUN mkdir /myapp 
WORKDIR /myapp 
ADD Gemfile /myapp/Gemfile 
ADD Gemfile.lock /myapp/Gemfile.lock 
RUN gem install bundler 
RUN bundle install 
ADD . /myapp 

FROM postgres:9.4 
#FROM library/postgres 
ENV POSTGRES_USER my-user-name 
ENV POSTGRES_PASSWORD '' 
ENV POSTGRES_DB app-database-name 

-

# docker-compose.yml 
version: '2' 
services: 
    db: 
    image: postgres 
    web: 
    build: . 
    command: bundle exec rails s -p 3000 -b '0.0.0.0' 
    volumes: 
     - .:/myapp 
    ports: 
     - "3000:3000" 
    depends_on: 
     - db 
+0

那些是單獨Dockerfiles?因爲你有兩條FROM指令。 – johnharris85

+0

@JHarris它是相同的DockerFile。我需要rails和postgres。 –

回答

1

你並不需要兩個指令在Dockerfile,只需使用搬運工,組成了覆蓋Postgres的enviroments圖像。

你可以試試這個:

# Dockerfile 
FROM ruby:2.2.3 

# Update ubuntu and deps 
RUN apt-get update -qq && apt-get install -y build-essential 

# Install postgres dep 
RUN apt-get install -y libpq-dev 

# Install nokogiri dep 
RUN apt-get install -y libxml2-dev libxslt1-dev 

# Install JS runtime 
RUN apt-get install -y nodejs 

ENV APP_HOME /app 
RUN mkdir $APP_HOME 
WORKDIR $APP_HOME 

ADD Gemfile* $APP_HOME/ 
# Install api deps 
RUN bundle install --jobs 4 

ADD . $APP_HOME 

現在你docker-compose.yml(我用的V1版本),你可以嘗試:

postgres: 
    image: postgres 
environment: 
    POSTGRES_USER: my-user-name 
    POSTGRES_PASSWORD: '' 
    POSTGRES_DB: app-database-name 

web: 
    build: . 
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -b '0.0.0.0'" 
    environment: 
    PORT: 3000 
    DATABASE_URL: 'postgres://postgres:@postgres:5432/postgres' 
    ports: 
    - '3000:3000' 
    link: 
    - db 
    volumes: 
    - .:/app 
相關問題