ソフトウェア/docker/Railsを動かす のバックアップ差分(No.2)

更新


  • 追加された行はこの色です。
  • 削除された行はこの色です。
[[公開メモ]]

* 参考にしたページ [#k6629f77]

https://qiita.com/okamos/items/8e9b258e3d610bdc2ed9

* library/ruby イメージ [#n6f054ca]

サイズは 55.5MB だった。

とりあえず雰囲気を確かめる。

 LANG:console
 $ docker run --rm -it ruby:alpine         # 何も指定しないと irb が立ち上がる
  irb(main):001:0>^D
 $ docker run --rm -it ruby:alpine bash    # bash は入っていない
  docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown.
 $ docker run --rm -it ruby:alpine sh      # sh は入ってる
 / # ls -l bin/sh                          # 正体は busybox
 /# ls -l bin/sh                           # 正体は busybox
  lrwxrwxrwx    1 root     root            12 Jan  9 19:37 bin/sh -> /bin/busybox
 /# ruby --version
  ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-musl]
 /# gem --version
  2.7.6
 /# bundle --version
  Bundler version 1.16.1
 /# gem install rails                      # 始めは gcc 等が入っていないのでコケる
  ...
  Fetching: nokogiri-1.8.2.gem (100%)
  Building native extensions. This could take a while...
  ERROR:  Error installing rails:
          ERROR: Failed to build gem native extension.
  ...
 /# apk add -U --no-cache bash git alpine-sdk nodejs tzdata  # いろいろ入れる
 /# gem install rails                      # これで入った
  ...
  Successfully installed rails-5.2.0
  30 gems installed
 /# rails new myapp
  ...
  Installing sqlite3 1.3.13 with native extensions
  Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
  ...
 /# apk add sqlite-dev
 /# rails new myapp                        # うまく行った
 /# cd myapp
 /myapp# rails s &                         # サーバーを起動
  => Booting Puma
  => Rails 5.2.0 application starting in development
  => Run `rails server -h` for more startup options
  Puma starting in single mode...
  * Version 3.11.4 (ruby 2.5.1-p57), codename: Love Song
  * Min threads: 5, max threads: 5
  * Environment: development
  * Listening on tcp://0.0.0.0:3000
  Use Ctrl-C to stop
 /myapp# wget -O- localhost:3000 | head -4 # 正しく読める
  Connecting to localhost:3000 (127.0.0.1:3000)
  Started GET "/" for 127.0.0.1 at 2018-05-09 20:02:41 +0000
  Processing by Rails::WelcomeController#index as HTML
    Rendering /usr/local/bundle/gems/railties-5.2.0/lib/rails/templates/rails/welcome/index.html.erb
    Rendered /usr/local/bundle/gems/railties-5.2.0/lib/rails/templates/rails/welcome/index.html.erb (3.0ms)
  Completed 200 OK in 6ms (Views: 4.5ms | ActiveRecord: 0.0ms)
  
  <!DOCTYPE html>
  <html>
  <head>
    <title>Ruby on Rails</title>
 /myapp#


Counter: 4726 (from 2010/06/03), today: 1, yesterday: 0