Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to run rails console using Docker Compose

Im quite new to Docker and have started using Docker Compose to run my rails 4 application in development on my OS X 10.10 machine. The rails app works fine but if i try to run the rails console using the command below:

docker-compose run web bundle exec rails console

or

docker-compose run web rails console

I get the following error:

Could not find CFPropertyList-2.3.1 in any of the sources Run bundle install to install missing gems.

I tried doing docker-compose run web bundle install, but i continue to get the same error. What could be the reason behind this ?. Below are my Dockerfile and docker-compose.yml .

Dockerfile

FROM ruby:2.2.0

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs npm nodejs-legacy
RUN npm install -g phantomjs

RUN mkdir /myapp
WORKDIR /myapp

ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock

RUN bundle install
ADD . /myapp

docker-compose.yml

version: '2'
services:
  db:
    image: postgres
  mailcatcher:
    image: yappabe/mailcatcher
    ports:
      - "1025:1025"
      - "1080:1080"
  web:
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    volumes:
      - .:/myapp
    ports:
      - "3000:3000"
    links:
      - db
      - mailcatcher
like image 925
joes Avatar asked Jun 23 '16 21:06

joes


People also ask

How do I open rails console in docker container?

# launch interactive bash on that running container docker exec -it $( docker ps | grep name_of_my_image | awk "{print \$1}" | head -n 1 ) bash # launch interactive rails console on that running container docker exec -it $( docker ps | grep name_of_my_image | awk "{print \$1}" | head -n 1 ) rails c # or if you don't ...

How do I get rails console?

Go to your browser and open http://localhost:3000, you will see a basic Rails app running. You can also use the alias "s" to start the server: bin/rails s . The server can be run on a different port using the -p option. The default development environment can be changed using -e .


1 Answers

You must use inside the root folder this:

docker-compose exec web rails console
like image 190
Pierangelo Orizio Avatar answered Sep 19 '22 15:09

Pierangelo Orizio