【问题标题】:web_1 | /docker-entrypoint.sh: line 99: exec: bundle: not found app_web_1 exited with code 127web_1 | /docker-entrypoint.sh:第 99 行:exec:bundle:未找到 app_web_1 退出,代码为 127
【发布时间】:2016-05-30 12:50:14
【问题描述】:

我正在尝试使用 docker 将我现有的 rails 项目推送到 docker 容器。

我正在使用 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

【问题讨论】:

  • 这些是单独的 Dockerfile 吗?因为你里面有两条 FROM 指令。
  • @JHarris 是同一个 DockerFile。我需要 rails 和 postgres。

标签: ruby-on-rails postgresql docker


【解决方案1】:

Dockerfile 中不需要两条指令,只需使用 docker-compose 覆盖 postgres 环境图像即可。

你可以试试这个:

# 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-05
    • 2021-06-04
    • 2020-05-19
    • 1970-01-01
    • 2019-05-02
    • 2018-07-13
    相关资源
    最近更新 更多