The dockerfile consists as:-
FROM ruby:2.2.3-slim
MAINTAINER Milan Rawal <[email protected]>
RUN apt-get update && apt-get install -qq -y build-essential nodejs libmagickcore-dev imagemagick libmagickwand-dev libxml2-dev libxslt1-dev git-core curl htop --fix-missing --no-install-recommends
ENV INSTALL_PATH /air_scout
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
COPY Gemfile Gemfile
RUN bundle install
COPY . .
RUN bundle exec rake RAILS_ENV=production SECRET_TOKEN=f6801f0744ff2e86b0baa542fc55075b5b79c922c518e34484cfe6a6c2149510973fa6c90d36c05907f8bf9114b6b33594f3630810b332ef3717b8b8f4f04b1f assets:precompile
VOLUME ["$INSTALL_PATH/public"]
CMD bundle exec unicorn -c config/unicorn.rb
And the docker-compose.yml file contains as:-
version: '2'
services:
mongodb:
image: mongo:latest
ports:
- '27017:27017'
volumes:
- air_scout-mongodb:/data/db
redis:
image: redis:3.0.5
ports:
- '6379:6379'
volumes:
- air_scout-redis:/var/lib/redis
air_scout:
build: .
ports:
- '8000:8000'
environment:
- DATABASE_URL=mongodb:27017
links:
- mongodb
- redis
env_file:
- .air_scout.env
resque:
build: .
environment:
- QUEUE=*
- DATABASE_URL=mongodb:27017
links:
- mongodb
- redis
command: bundle exec rake environment resque:work
env_file:
- .air_scout.env
volumes:
air_scout-redis:
air_scout-mongodb:
When I do "docker-compose build" every thing build properly and when I do "docker-compose up" then the app boots and I'm able to access the app running in air_scout container on vm host, but on db access app. page I get error as:
"air_scout_1 | [fe9cdec8-36e4-4974-aef3-18b1e73ea030] [DEBUG] MONGODB | Connection refused - connect(2) for 127.0.0.1:27017".
In my mongoid.yml file I have did config like below:
hosts:
- localhost:27017
- <%= ENV['DATABASE_URL'] %>
What actually is the issue, I'm really banging my head since yesterday. Thankyou.
Doing "docker inspect CID" gives the json data in which the Ipaddress under Networsetting is "" empty. How can I access this empty IP.
EDIT:- contents in mongoid.yml file is as:-
production:
clients:
default:
database: air_scout_test
hosts:
- localhost:27017
- <%= ENV['DATABASE_URL'] %>
options:
max_pool_size: 1
options:
raise_not_found_error: false