我在docker-compose网络中遇到了Rails容器的问题。几个月以来我都没有碰过它,当我本周尝试启动它时,它失败了。
当我尝试使用docker-compose up service
启动容器时,启动失败并显示:
service_1 | Could not locate Gemfile or .bundle/ directory
support_portal_service_1 exited with code 10
两个文件都存在,主机是Windows 10计算机。
Bundle install
成功完成:
Bundle complete! 19 Gemfile dependencies, 83 gems now installed.
Bundled gems are installed into `/usr/local/bundle`
我尝试过的事情:
ADD Gemfile /app/Gemfile
更改为COPY Gemfile /app/Gemfile
Gemfile.lock /app/Gemfile.lock
bundle install
这是我的Dockerfile
:
FROM ruby:2.5.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs default-libmysqlclient-dev ruby ruby-all-dev
RUN mkdir /app
WORKDIR /app
COPY Gemfile /app/Gemfile
#COPY Gemfile.lock /app/Gemfile.lock
WORKDIR /app
RUN bundle install
ADD . /app
还有我的docker-compose.yml
:
version: '2'
services:
# Structured database
sqldb:
image: mysql:5.7
volumes:
- sql:/var/lib/mysql
env_file:
- .env
environment:
- MYSQL_USER=web
- MYSQL_ROOT_PASSWORD=${PORTAL_DATABASE_PASSWORD}
- MYSQL_PASSWORD=${PORTAL_DATABASE_PASSWORD}
ports:
- "3306:3306"
# Application server
service:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/app
env_file:
- .env
expose:
- "3000"
depends_on:
- sqldb
# Front end proxy
web:
image: nginx
build:
context: .
dockerfile: Dockerfile-web
depends_on:
- service
ports:
- "80:80"
- "144:144"
# Persistence
volumes:
sql: