首页 > 解决方案 > Docker:bash:bundle:找不到命令

问题描述

我正在尝试对我的 Rails 6 应用程序进行 Dockerize 化,但似乎遇到了最后一个障碍。运行时docker-compose up一切正常,直到我在控制台中进入“附加到 rdd-ruby_db_1,rdd-ruby_web_1”,然后我得到错误bash: bundle: command not found

我知道 Stackoverflow 上针对同一问题的其他答案,但在发布此问题之前我已经尝试了所有方法。

我的 Dockerfile:

FROM ruby:2.7
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN cd /usr/bin/
RUN bundle install
FROM node:6.7.0
RUN npm install -g yarn
COPY . /myapp

# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
EXPOSE 3000

# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]

我的码头工人撰写

version: '3'
services:
  db:
    image: postgres
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: xxx
  web:
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - .:/myapp
    ports:
      - "3000:3000"
    depends_on:
      - db

我最初遵循 Docker 文档中的指南,认为这可以在https://docs.docker.com/compose/rails/

谢谢。

标签: ruby-on-railsdocker

解决方案


推荐阅读