I'm having some issues when trying to run rails console under docker. All other rails commands work as expected, but console does not.
➜ octopus git:(master) ✗ docker-compose run web bundle exec rails c
Creating octopus_web_run ... done
Could not find rake-13.0.6 in any of the sources
Run `bundle install` to install missing gems.
ERROR: 1
rake is installed.
➜ octopus git:(master) ✗ docker-compose run web bundle install
Creating octopus_web_run ... done
Using rake 13.0.6
Using concurrent-ruby 1.1.9
Using i18n 1.8.11
....
Bundle complete! 42 Gemfile dependencies, 144 gems now installed.
Bundled gems are installed into `./.bundle`
More over
➜ octopus git:(master) ✗ docker-compose run web bundle config list
Creating octopus_web_run ... done
Settings are listed in order of priority. The top value will be used.
app_config
Set via BUNDLE_APP_CONFIG: "/myapp/.bundle"
silence_root_warning
Set via BUNDLE_SILENCE_ROOT_WARNING: true
path
Set via BUNDLE_PATH: "/myapp/.bundle"
bin
Set via BUNDLE_BIN: "/bin"
➜ octopus git:(master) ✗ docker-compose run web bundle exec rails s -p 3000 -b '0.0.0.0'
Creating octopus_web_run ... done
=> Booting Puma
=> Rails 6.1.4.4 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.5.2 (ruby 2.7.5-p203) ("Zawgyi")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 1
* Listening on http://0.0.0.0:3000
Use Ctrl-C to stop
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2022-01-17 19:28:14 +0000 ===
- Goodbye!
Exiting
And also docker-compose up work as usual.
I've worked with many similar docker setup without any issue. I'm running out of ideas.
Environment setup
- gems are under ./bundle
- docker-compose version 1.29.2
- ruby 2.7
- rails 6.1.4.4
Dockerfile
FROM ruby:2.7
RUN curl -fsSL https://deb.nodesource.com/setup_17.x | bash -
# Install yarn, for webpack
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs yarn
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
ENV GEM_HOME /myapp/.bundle
ENV BUNDLE_PATH=$GEM_HOME \
BUNDLE_APP_CONFIG=$BUNDLE_PATH \
BUNDLE_BIN=$BUNDLE_PATH/bin
ENV PATH /app/bin:$BUNDLE_BIN:$PATH
ENV NODE_OPTIONS=--openssl-legacy-provider
Docker-compose.yml
version: '3.9'
services:
db:
image: postgres:13
volumes:
- octopus-db-sync:/var/lib/postgresql/data:nocopy
environment:
POSTGRES_PASSWORD: password
redis:
image: redis
web:
build: .
command: ./start_docker_development.sh
volumes:
- octopus-sync:/myapp:nocopy
environment:
BUNDLE_APP_CONFIG: /myapp/.bundle
ports:
- "3000:3000"
depends_on:
- db
- redis
- mailcatcher
nginx:
image: nginx
volumes:
- ./nginx-develop.conf:/etc/nginx/conf.d/default.conf:z
- octopus-sync:/myapp:nocopy
ports:
- "80:80"
expose:
- "80"
depends_on:
- web
mailcatcher:
image: sj26/mailcatcher
ports:
- "1080:1080"
volumes:
octopus-sync:
external: true
octopus-db-sync:
external: true
start_docker_development.sh
#!/bin/bash
bundle check || bundle install
rm -f tmp/pids/server.pid
echo > log/development.log
echo > log/test.log
bundle exec rails s -p 3000 -b '0.0.0.0'
Any help is much appreciate.