質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

解決済

1回答

991閲覧

docker開発環境で作ったページがブラウザに表示されない

asm_t

総合スコア14

docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

0グッド

0クリップ

投稿2021/07/04 07:15

編集2021/07/04 08:24

docker初学者です。
Docker+Rails6+Puma+Nginx+MySQLで環境構築を完了させ、これからアプリ開発を始めようとしています。

少しページを作って表示されるか確認したところ、railsの初期ページ(「Yay! You're on Rails!」)のまま更新されずに困っております。

ブラウザでhttp://localhost/にアクセスした結果の画像を添付させていただきます。![イメージ説明](4fcdadb77e451df001e640d1e4b581fc.png)

なお、マウントはdocker-compose.yml内のvolumes:により指定しています。

# docker-compose.yml version: "3" services: app: build: context: . env_file: - ./environments/db.env command: bundle exec puma -C config/puma.rb volumes: - .:/var/www/remote-work-space - public-data:/var/www/remote-work-space/public - tmp-data:/var/www/remote-work-space/tmp - log-data:/var/www/remote-work-space/log depends_on: - db db: image: mysql:5.7 env_file: - ./environments/db.env volumes: - db-data:/var/lib/mysql web: build: context: containers/nginx volumes: - public-data:/var/www/remote-work-space/public - tmp-data:/var/www/remote-work-space/tmp ports: - 80:80 depends_on: - app volumes: public-data: tmp-data: log-data: db-data:

コンテナの中身を確認した結果

root@edbae24ba02a:/var/www/remote-work-space/app/models# cat tweet.rb class Tweet < ApplicationRecord end
root@edbae24ba02a:/var/www/remote-work-space/app/views/tweets# cat index.html.erb <div class="contents row"> <% @tweets.each do |tweet| %> <div class="content_post" > <p><%= tweet.text %></p> <span class="name"> <%= tweet.name %> </span> </div> <% end %>
root@edbae24ba02a:/var/www/remote-work-space/app/controllers# cat tweets_controller.rb class TweetsController < ApplicationController def index @tweets = Tweet.all end end
root@edbae24ba02a:/var/www/remote-work-space/config# cat routes.rb Rails.application.routes.draw do get 'tweets/index' resources :tweets, only: :index end

上記の通り、ローカル環境で作ったファイルがコンテナに接続されているのが確認できました。

それにもかかわらず、なぜrailsの初期ページのままの表示になってしまうのでしょうか。
まだまだdockerの勉強が足りていない状況での質問で申し訳ございませんが、
ご教示いただけますと幸いです。
よろしくお願いいたします。

追記

$ docker-compose logsの結果です。

$ docker-compose logs Attaching to remote-work-space_web_1, remote-work-space_app_1, remote-work-space_db_1 app_1 | Puma starting in single mode... app_1 | * Puma version: 5.3.2 (ruby 3.0.0-p0) ("Sweetnighter") app_1 | * Min threads: 5 app_1 | * Max threads: 5 app_1 | * Environment: development app_1 | * PID: 1 app_1 | * Listening on http://0.0.0.0:3000 app_1 | * Listening on unix:///var/www/remote-work-space/tmp/sockets/puma.sock app_1 | Use Ctrl-C to stop app_1 | Puma starting in single mode... app_1 | * Puma version: 5.3.2 (ruby 3.0.0-p0) ("Sweetnighter") app_1 | * Min threads: 5 app_1 | * Max threads: 5 app_1 | * Environment: development app_1 | * PID: 1 app_1 | * Listening on http://0.0.0.0:3000 app_1 | * Listening on unix:///var/www/remote-work-space/tmp/sockets/puma.sock app_1 | Use Ctrl-C to stop db_1 | 2021-07-03 15:12:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.34-1debian10 started. db_1 | 2021-07-03 15:12:15+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' db_1 | 2021-07-03 15:12:15+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.34-1debian10 started. db_1 | 2021-07-03T15:12:15.378988Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). db_1 | 2021-07-03T15:12:15.380901Z 0 [Note] mysqld (mysqld 5.7.34) starting as process 1 ... db_1 | 2021-07-03T15:12:15.386624Z 0 [Note] InnoDB: PUNCH HOLE support available ・ ・ ・ ・ ・ db_1 | 2021-07-03T15:12:15.546167Z 0 [Note] - '::' resolves to '::'; db_1 | 2021-07-03T15:12:15.546330Z 0 [Note] Server socket created on IP: '::'. db_1 | 2021-07-03T15:12:15.557366Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. db_1 | 2021-07-03T15:12:15.571221Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210703 15:12:15 db_1 | 2021-07-03T15:12:15.616840Z 0 [Note] Event Scheduler: Loaded 0 events db_1 | 2021-07-03T15:12:15.617428Z 0 [Note] mysqld: ready for connections. db_1 | Version: '5.7.34' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL) db_1 | 2021-07-03T15:48:07.462724Z 6 [Note] Access denied for user 'user'@'localhost' (using password: YES) ・ ・ ・ ・ db_1 | 2021-07-04T04:47:54.370144Z 0 [Note] Shutting down plugin 'binlog' db_1 | 2021-07-04T04:47:54.388495Z 0 [Note] mysqld: Shutdown complete db_1 | db_1 | 2021-07-04 04:47:57+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.34-1debian10 started. db_1 | 2021-07-04 04:47:58+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' db_1 | 2021-07-04 04:47:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.34-1debian10 started. db_1 | 2021-07-04T04:47:58.614911Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). db_1 | 2021-07-04T04:47:58.617698Z 0 [Note] mysqld (mysqld 5.7.34) starting as process 1 ... db_1 | 2021-07-04T04:47:58.623720Z 0 [Note] InnoDB: PUNCH HOLE support available ・ ・ ・ ・ db_1 | 2021-07-04T05:40:34.661009Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210704 5:40:34 db_1 | 2021-07-04T05:40:34.665442Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. db_1 | 2021-07-04T05:40:34.665854Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory. db_1 | 2021-07-04T05:40:34.666737Z 0 [Warning] CA certificate ca.pem is self signed. db_1 | 2021-07-04T05:40:34.667167Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory. ・ ・ ・ db_1 | 2021-07-04T06:29:28.513531Z 0 [Note] Shutting down plugin 'INNODB_TRX' db_1 | 2021-07-04T06:29:28.513545Z 0 [Note] Shutting down plugin 'InnoDB' db_1 | 2021-07-04T06:29:28.513726Z 0 [Note] InnoDB: FTS optimize thread exiting. ・ ・ ・ ・ db_1 | 2021-07-04 06:29:34+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.34-1debian10 started. db_1 | 2021-07-04 06:29:35+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' db_1 | 2021-07-04 06:29:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.34-1debian10 started. db_1 | 2021-07-04T06:29:36.209276Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). db_1 | 2021-07-04T06:29:36.211587Z 0 [Note] mysqld (mysqld 5.7.34) starting as process 1 ... db_1 | 2021-07-04T06:29:36.217955Z 0 [Note] InnoDB: PUNCH HOLE support available ・ ・ ・ ・ db_1 | 2021-07-04T06:29:36.417135Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool db_1 | 2021-07-04T06:29:36.417314Z 0 [Note] Plugin 'FEDERATED' is disabled. db_1 | 2021-07-04T06:29:36.420323Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210704 6:29:36 db_1 | 2021-07-04T06:29:36.441138Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. db_1 | 2021-07-04T06:29:36.442357Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory. db_1 | 2021-07-04T06:29:36.446992Z 0 [Warning] CA certificate ca.pem is self signed. db_1 | 2021-07-04T06:29:36.447793Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory. db_1 | 2021-07-04T06:29:36.456602Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 db_1 | 2021-07-04T06:29:36.458406Z 0 [Note] IPv6 is available. db_1 | 2021-07-04T06:29:36.458756Z 0 [Note] - '::' resolves to '::'; db_1 | 2021-07-04T06:29:36.458803Z 0 [Note] Server socket created on IP: '::'. db_1 | 2021-07-04T06:29:36.464235Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. db_1 | 2021-07-04T06:29:36.576462Z 0 [Note] Event Scheduler: Loaded 0 events db_1 | 2021-07-04T06:29:36.578205Z 0 [Note] mysqld: ready for connections. db_1 | Version: '5.7.34' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL) ・ ・ ・ ・ db_1 | 2021-07-04T08:00:29.850835Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory. db_1 | 2021-07-04T08:00:29.864156Z 0 [Warning] CA certificate ca.pem is self signed. db_1 | 2021-07-04T08:00:29.864359Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory. db_1 | 2021-07-04T08:00:29.871403Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 db_1 | 2021-07-04T08:00:29.871770Z 0 [Note] IPv6 is available. db_1 | 2021-07-04T08:00:29.871958Z 0 [Note] - '::' resolves to '::'; db_1 | 2021-07-04T08:00:29.871999Z 0 [Note] Server socket created on IP: '::'. db_1 | 2021-07-04T08:00:29.883021Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. db_1 | 2021-07-04T08:00:30.085056Z 0 [Note] Event Scheduler: Loaded 0 events db_1 | 2021-07-04T08:00:30.087712Z 0 [Note] mysqld: ready for connections. db_1 | Version: '5.7.34' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)

よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

自己解決しました。
config/routes.rbに以下の記述が漏れておりました。
root 'tweets#index'

上記を記載することでちゃんと開発したページを表示させることができました!

投稿2021/07/04 13:06

asm_t

総合スコア14

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問