I am trying to use docker on with a rails apps. This setup works on other developers machines, but not mine. I can get the mysql to "up" but not the rails app. I've been at it for 2 days now.
I'm on windows 10 home using the Docker Quickstart Terminal. I was able to run this about a year ago on the same machine.
Here is my Dockerfile:
FROM ruby:2.5.3
ARG workdir=/bundle-api
RUN apt-get update -qq && apt-get install -y build-essential netcat graphviz
RUN mkdir -p ${workdir}
WORKDIR ${workdir}
ADD Gemfile ${workdir}/Gemfile
ADD Gemfile.lock ${workdir}/Gemfile.lock
RUN bundle install
ADD . ${workdir}
Here is my docker-compose file:
version: '2'
services:
db:
image: mysql:5.7
container_name: bundle-mysql
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: bundle_api_pwd
MYSQL_DATABASE: bundle_api_dev
MYSQL_USER: bundle_api
MYSQL_PASSWORD: bundle_api_pwd
ports:
- "3306:3306"
web:
build: .
container_name: bundle-rails
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/bundle-api:cached
- bundle_cache:/bundle_cache
ports:
- "3100:3000"
environment:
DB_HOST: db
DB_USERNAME: root
DB_PASSWORD: bundle_api_pwd
BUNDLE_PATH: /bundle_cache
GEM_HOME: /bundle_cache
GEM_PATH: /bundle_cache
depends_on:
- db
stdin_open: true
tty: true
bundle_cache:
image: busybox
volumes:
- bundle_cache:/bundle_cache
volumes:
db_data:
bundle_cache:
To start fresh I run this: docker-compose build --no-cache
Everything seems to work fine. I can see all the gems install.
Once it runs, I run: docker-compose up
and get this error.
bundle-rails | Could not locate Gemfile or .bundle/ directory
bundle-rails exited with code 10
Name Command State Ports
------------------------------------------------------------------------------------------------------------
bundle-backend_bundle_cache_1 sh Exit 0
bundle-mysql docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp, 33060/tcp
bundle-rails bundle exec rails s -p 300 ... Exit 10
Looks like you are setting BUNDLE_PATH
in the docker-compose.yml
but you don't set it in the Dockerfile
. That means you gems will be installed to /usr/local/bundle
but then when you start the container ruby looks in /bundle-cache
for the gems.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.