我正在运行两个docker容器。一个用rails和一个用Postgres db。 这里是我的搬运工,撰写文件:在rails docker容器中找不到rake-11.1.2
# Docs: https://docs.docker.com/compose/compose-file/
version: '2'
services:
db:
image: postgres
environment:
- POSTGRES_PASSWORD=xxx
rails:
build: .
command: rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/app
ports:
- "3000:3000"
links:
- db
depends_on:
- db
这里Dockerfile的Rails应用程序:
FROM ruby:2.3
RUN apt-get update
RUN apt-get install -y build-essential nodejs
RUN mkdir -p /app
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install --jobs 20 --retry 5
COPY . ./
EXPOSE 3000
ENTRYPOINT ["bundle", "exec"]
CMD ["rails", "server", "-b", "0.0.0.0"]
当我运行docker-compose up
一切工作正常,我可以通过从IP地址连接到服务器泊坞窗机。
当我尝试连接到使用以下命令容器:
docker-compose run rails console
我得到这个错误:
Could not find rake-11.1.2 in any of the sources
Run `bundle install` to install missing gems.
束装在容器内没有任何作用,所提到的宝石,绝对是安装。在其他堆栈溢出问题中提到我应该运行bin/spring stop
。所以,我跑:
docker-compose run bin/spring stop
,并返回:
Spring is not running
我还是comparibly新的Ruby/Rails和码头工人。我希望有人能帮助我! 在此先感谢
PS:对Dockerfiles的评论表示赞赏!
我有完全相同的问题! – JacobEvelyn