DockerでRails環境を構築。 下記にあるDocker Hub から"sumura80/docker-rails"をdocker上で取得します。 https://hub.docker.com/r/sumura80/docker-rails
取得とコンテナの作成と開始方法: Terminal上で下記のコマンドを実行してください。
docker pull sumura80/docker-rails (イメージの取得)
docker-compose build (サービスの構築・実行)
docker-compose run web rake db:create (データベースの作成)
docker-compose up (サーバーの起動)
localhost:3000 にアクセス
アプリ名: myrailsapp
Ruby:2.5.0
Rails: 5.1.7
DB: postgresql
FROM ruby:2.5.0
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
WORKDIR /myrailsapp
ADD Gemfile /myrailsapp/Gemfile
ADD Gemfile.lock /myrailsapp/Gemfile.lock
RUN gem install bundler
RUN bundle install
ADD . /myrailsapp
version: '3'
services:
db:
image: postgres
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
ports:
- "3000:3000"
volumes:
- .:/myrailsapp
depends_on:
- db
volumes:
postgresql-data:
driver: local
GitHubとDocker Hubを連携させている。 イメージのpullに少し時間がかかる。
Content type
Image
Digest
Size
400.7 MB
Last updated
about 7 years ago
docker pull sumura80/docker-rails