Docker migrations

I am trying to run a rails application using docker and fig, it counts with the redis, mongodb, postgres and nginx server. Here is my fig.yml:

pg:
  image: docker-index.my.com/postgres
  ports:
    - 5432
redis:
  image: docker-index.my.com/redis
  ports:
    - 6379
mongodb:
  image: docker-index.my.com/mongodb
  ports:
    - 27017
app:
  build: .
  command: bundle exec rails s
  volumes:
    - .:/beesor
  ports:
    - 3000:3000
  links:
    - pg
    - redis
    - mongodb
  environment:
    RAILS_ENV: production

Everything works fine until the application is launched, since the rail initializers are launched on the server, then I received errors regarding the connection to the database, the database does not exist! of course, because it was not created in the Docker file (see below)

Dockerefile Content:

# DOCKER-VERSION 0.10.0
FROM docker-index.my.com/ruby:1.9.3
MAINTAINER my.com

RUN apt-get update -qq && apt-get install -y git-core xvfb curl nodejs libqt4-dev libgtk2.0-0 libgtkmm-3.0-1 libnotify4 sqlite3 libsqlite3-dev graphicsmagick imagemagick subversion libpq-dev libxml2-dev libxslt-dev git build-essential
RUN mkdir /my_app
WORKDIR /my_app

RUN gem install bundler

ADD Gemfile /my_app/Gemfile
ADD Gemfile.lock /my_app/Gemfile.lock
RUN bundle install
RUN bundle pack --all
ADD . /my_app

, rake db: create db: migrate db: seed commands!, Docker, , fig , , ( , fig , ), fig.yml, , ?

, , .

+4
1

!:

, , , , , , :

: rake my_app: setup

+1

Source: https://habr.com/ru/post/1537561/


All Articles