Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
すぐできるDocker
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
hidekuni KAJITA
January 25, 2018
Programming
1.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
すぐできるDocker
2018 アジャイル事業部 年始のご挨拶
hidekuni KAJITA
January 25, 2018
More Decks by hidekuni KAJITA
See All by hidekuni KAJITA
あれのその後.pdf
hidenba
0
42
NVIDIABroadcast便利
hidenba
0
150
レバーレスアケコンを作った話
hidenba
0
91
「冒険できる社会」を実現する “あしたのチーム”
hidenba
0
180
DataChannel を利用した ホワイトボードアプリ開発事例
hidenba
0
1.1k
リズムから生まれるアジャイルな開発
hidenba
0
630
Other Decks in Programming
See All in Programming
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
520
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
380
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
460
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
520
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
3.1k
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
速習iPhone Duo対応
yuukiw00w
2
920
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
120
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5.3k
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
5.7k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
410
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.7k
Featured
See All Featured
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
530
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Mobile First: as difficult as doing things right
swwweet
225
10k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Mind Mapping
helmedeiros
1
390
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
The Limits of Empathy - UXLibs8
cassininazir
1
690
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Believing is Seeing
oripsolob
1
240
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
Designing for humans not robots
tammielis
254
26k
エンジニアに許された特別な時間の終わり
watany
109
250k
Transcript
すぐできる Docker かじたひでくに 2018/01/24
自己紹介 梶田英邦(かじたひでくに) @hide_nba Ruby/Railsを使ってお仕事して ます 2018年7月を担当
やってみよう! YARIMASU!!
Dockerfileの作成 FROM ruby:2.5 RUN groupadd --gid 1000 developer \ &&
useradd --uid 1000 --gid developer --shell /bin/bash --create-home developer RUN apt-get update && apt-get install -y nodejs ENV APP_HOME /usr/src/app RUN mkdir -p $APP_HOME WORKDIR $APP_HOME COPY Gemfile \ Gemfile.lock \ $APP_HOME/ ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \ BUNDLE_JOBS=4
docker-compose.ymlの 作成 version: '3' services: db: image: mysql ports: -
"3306:3306" volumes: - mysql_data:/var/lib/mysql app: build: . user: 1000:1000 command: bin/rails s -p 3000 -b "0.0.0.0" depends_on: - db ports: - "3000:3000" stdin_open: true tty: true volumes: - .:/usr/src/app - bundle_cache:/usr/local/bundle volumes: bundle_cache: mysql_data:
Gemfileの作成 # frozen_string_literal: true source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "rails"
Gemfile.lockの作成 $ touch Gemfile.lock
bundle install $ docker-compose run app bundle install
rails new $ docker-compose run app rails new . --force
--database mysql
config/database.ymlの 編集 diff --git a/config/database.yml b/config/database.yml index 6003576..2213f5b 100644 ---
a/config/database.yml +++ b/config/database.yml @@ -14,8 +14,7 @@ default: &default encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root - password: - host: localhost + host: db development: <<: *default
サーバ起動 $ docker-compose up
動いた!
Dockerfile FROM ruby:2.5 RUN groupadd --gid 1000 developer \ &&
useradd --uid 1000 --gid developer --shell /bin/bash --create-home developer RUN apt-get update && apt-get install -y nodejs ENV APP_HOME /usr/src/app RUN mkdir -p $APP_HOME WORKDIR $APP_HOME COPY Gemfile \ Gemfile.lock \ $APP_HOME/ ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \ BUNDLE_JOBS=4
FROM FROM ruby:2.5 Rubyのバージョン2.5が入ってい るイメージを利用する
groupadd && useradd RUN groupadd --gid 1000 developer \ &&
useradd --uid 1000 --gid developer --shell /bin/bash --create-home developer イメージ内にグループID(1000)と ユーザID(1000)のグループとユー ザを作成
WORKDIR ENV APP_HOME /usr/src/app RUN mkdir -p $APP_HOME WORKDIR $APP_HOME
イメージ内に /usr/src/app を 作成してコンテナ実行時の作業 ディレクトとする
BUNDLE_XXXX ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \ BUNDLE_JOBS=4 bundlerの設定
docker-compose.yml version: '3' services: db: image: mysql ports: - "3306:3306"
volumes: - mysql_data:/var/lib/mysql app: build: . user: 1000:1000 command: bin/rails s -p 3000 -b "0.0.0.0" depends_on: - db ports: - "3000:3000" stdin_open: true tty: true volumes: - .:/usr/src/app - bundle_cache:/usr/local/bundle volumes: bundle_cache: mysql_data:
named volume volumes: bundle_cache: mysql_data: この名前でvolumeのマウントを 行える 永続化する場所を気にせずにお 手軽
データベース設定 services: db: image: mysql ports: - "3306:3306" volumes: -
mysql_data:/var/lib/mysql サービス名はコンテナ間の名前解 決にも利用される
services.db image: mysql mysqlのイメージを使用する ports: ホスト側とコンテナ側の使用ポート volumes: mysql_dataをコンテナ側の /var/lib/ mysql
をマウントする
アプリケーション設定 services: app: build: . user: 1000:1000 command: bin/rails s
-p 3000 -b "0.0.0.0" depends_on: - db ports: - "3000:3000" stdin_open: true tty: true volumes: - .:/usr/src/app - bundle_cache:/usr/local/bundle
services.app(1) build . カレントディレクトリのDockerfileをビ ルドする user: 1000:1000 UID/GID 1000 でコマンドを実行する
services.app(2) command: bin/rails s -p 3000 -b “0.0.0.0” コンテナ起動時に実行されるコマンド depends_on:
-db dbコンテナが起動してから起動するよう に設定
services.app(3) volumes: - .:/usr/src/app ホスト側のカレントディレクト リをコンテナ側の/usr/src/app にマウント
まとめ Docker便利!! 簡単に使い始められるのでドンド ン使っていきましょう!