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

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

新規登録して質問してみよう
ただいま回答率
85.47%
Ruby on Rails 6

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

MySQL

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

Docker

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

Q&A

1回答

1155閲覧

Mysql2::Error::ConnectionError: Access denied for user 'root'@'172.19.0.4' (using password: YES)

tomsuma

総合スコア38

Ruby on Rails 6

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

MySQL

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

Docker

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

0グッド

0クリップ

投稿2020/09/08 05:14

編集2020/09/08 09:50

既存アプリにdockerを導入中にエラーが起きて困っています

参考記事

イメージ説明
試したコマンド

docker-compose ps Name Command State Ports ------------------------------------------------------------------------------ books_db_1 docker-entrypoint.sh mysqld Up 0.0.0.0:4306->3306/tcp books_web_1 entrypoint.sh bash -c rm - ... Exit 1
user@fukusyun-2 Books % docker search registry NAME DESCRIPTION STARS OFFICIAL AUTOMATED registry The Docker Registry 2.0 implementation for s… 3068 [OK] distribution/registry WARNING: NOT the registry official image!!! … 57 [OK] stefanscherer/registry-windows Containerized docker registry for Windows Se… 32 budry/registry-arm Docker registry build for Raspberry PI 2 and… 18 deis/registry Docker image registry for the Deis open sour… 12 jc21/registry-ui A nice web interface for managing your Docke… 12 anoxis/registry-cli You can list and delete tags from your priva… 10 [OK] allingeek/registry A specialization of registry:2 configured fo… 4 [OK] pallet/registry-swift Add swift storage support to the official do… 4 [OK] arm32v6/registry The Docker Registry 2.0 implementation for s… 3 goharbor/registry-photon 2 webhippie/registry Docker images for Registry 1 [OK] conjurinc/registry-oauth-server Docker registry authn/authz server backed by… 1 ibmcom/registry Docker Image for IBM Cloud private-CE (Commu… 1 concourse/registry-image-resource 1 metadata/registry Metadata Registry is a tool which helps you … 1 [OK] upmcenterprises/registry-creds 0 kontena/registry Kontena Registry 0 dwpdigital/registry-image-resource Concourse resource type 0 gisjedi/registry-proxy Reverse proxy of registry mirror image gisje… 0 lorieri/registry-ceph Ceph Rados Gateway (and any other S3 compati… 0 convox/registry 0 digillect/registry-cleaner Tool to remove unused images from Docker reg… 0 [OK] pivnet/registry-gcloud-image 0 deepsecurity/registryviews Deep Security Smart Check 0
docker-compose run web rails db:migrate RAILS_ENV=production Starting books_db_1 ... done Creating books_web_run ... done DEPRECATION WARNING: Including LoggerSilence is deprecated and will be removed in Rails 6.1. Please use `ActiveSupport::LoggerSilence` instead (called from <main> at /Books/config/application.rb:7)

database.yml

1 2default: &default 3 adapter: mysql2 4 encoding: utf8 5 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 6 username: root 7 password: example 8 # socket: /tmp/mysql.sock 9 10 host: db 11 12development: 13 <<: *default 14 database: Books_development 15 16test: 17 <<: *default 18 database: Books_test 19 20production: 21 <<: *default 22 database: Books_production 23 24 username: root 25 password: <%= ENV['DATABASE_PASSWORD'] %> 26 # socket: /var/lib/mysql/mysql.sock

webpacker.yml

1# Note: You must restart bin/webpack-dev-server for changes to take effect 2 3default: &default 4 source_path: app/javascript 5 source_entry_path: packs 6 public_root_path: public 7 public_output_path: packs 8 cache_path: tmp/cache/webpacker 9 check_yarn_integrity: false 10 webpack_compile_output: true 11 12 # Additional paths webpack should lookup modules 13 # ['app/assets', 'engine/foo/app/assets'] 14 resolved_paths: [] 15 16 # Reload manifest.json on all requests so we reload latest compiled packs 17 cache_manifest: false 18 19 # Extract and emit a css file 20 extract_css: false 21 22 static_assets_extensions: 23 - .jpg 24 - .jpeg 25 - .png 26 - .gif 27 - .tiff 28 - .ico 29 - .svg 30 - .eot 31 - .otf 32 - .ttf 33 - .woff 34 - .woff2 35 36 extensions: 37 - .mjs 38 - .js 39 - .sass 40 - .scss 41 - .css 42 - .module.sass 43 - .module.scss 44 - .module.css 45 - .png 46 - .svg 47 - .gif 48 - .jpeg 49 - .jpg 50 51development: 52 <<: *default 53 compile: true 54 55 # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules 56 check_yarn_integrity: false 57 58 # Reference: https://webpack.js.org/configuration/dev-server/ 59 dev_server: 60 https: false 61 host: localhost 62 public: localhost:3035 63 hmr: false 64 # Inline should be set to true if using HMR 65 inline: true 66 overlay: true 67 compress: true 68 disable_host_check: true 69 use_local_ip: false 70 quiet: false 71 pretty: false 72 headers: 73 'Access-Control-Allow-Origin': '*' 74 watch_options: 75 ignored: '**/node_modules/**' 76 77 78test: 79 <<: *default 80 compile: true 81 82 # Compile test packs to a separate directory 83 public_output_path: packs-test 84 85production: 86 <<: *default 87 88 # Production depends on precompilation of packs prior to booting for performance. 89 compile: false 90 91 # Extract and emit a css file 92 extract_css: true 93 94 # Cache manifest.json for performance 95 cache_manifest: true 96

dockerfile

1FROM ruby:2.6 2 3# APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn 4 5RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ 6 && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list 7 8RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs yarn 9 10WORKDIR /Books/ 11COPY Gemfile ./Gemfile 12COPY Gemfile.lock ./Gemfile.lock 13RUN gem install bundler 14RUN bundle install 15COPY . /Books/ 16 17# Add a script to be executed every time the container starts. 18COPY entrypoint.sh /usr/bin/ 19RUN chmod +x /usr/bin/entrypoint.sh 20ENTRYPOINT ["entrypoint.sh"] 21EXPOSE 3000 22 23# Start the main process. 24CMD ["rails", "server", "-b", "0.0.0.0"]

docker

1version: '3' 2services: 3 db: 4 image: mysql:5.6 #既存アプリとあわせる。ターミナルに「mysqladmin version」で確認 5 environment: 6 MYSQL_ROOT_PASSWORD: example 7 MYSQL_DATABASE: root 8 ports: 9 - "4306:3306" #Sequel ProでDBを確認する為、4306としておく 10 volumes: 11 - mysql-data:/var/lib/mysql 12 web: 13 build: . 14 command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" 15 volumes: 16 - .:/Books 17 ports: 18 - 3000:3000 19 depends_on: 20 - db 21 tty: true 22 stdin_open: true 23volumes: 24 mysql-data:

entrypoint.sh

1#!/bin/bash 2set -e 3 4# Remove a potentially pre-existing server.pid for Rails. 5rm -f /Books/tmp/pids/server.pid 6 7# Then exec the container's main process (what's set as CMD in the Dockerfile). 8exec "$@"

build時にエラー

1 2Retrying download gem from https://rubygems.org/ due to error (2/4): Gem::RemoteFetcher::UnknownHostError no such name (https://rubygems.org/gems/rails-dom-testing-2.0.3.gem) 3省略 4Retrying download gem from https://rubygems.org/ due to error (3/4): Gem::RemoteFetcher::UnknownHostError no such name (https://rubygems.org/gems/rails-dom-testing-2.0.3.gem) 5* If you use Sass as a command-line tool, we recommend using Dart Sass, the new 6 primary implementation: https://sass-lang.com/install 7 8* If you use Sass as a plug-in for a Ruby web framework, we recommend using the 9 sassc gem: https://github.com/sass/sassc-ruby#readme 10 11* For more details, please refer to the Sass blog: 12 https://sass-lang.com/blog/posts/7828841 13 14Removing intermediate container 8bd9d59f8a9e 15 ---> 5f8ccb68b6a8 16Step 9/14 : COPY . /Books/ 17 ---> bae50ec6a18f 18Step 10/14 : COPY entrypoint.sh /usr/bin/ 19 ---> 73e8ff54cc78 20Step 11/14 : RUN chmod +x /usr/bin/entrypoint.sh 21 ---> Running in b7e08fdfeb7a 22Removing intermediate container b7e08fdfeb7a 23 ---> 5d4266538f2d 24Step 12/14 : ENTRYPOINT ["entrypoint.sh"] 25 ---> Running in 570b3b80ed3f 26Removing intermediate container 570b3b80ed3f 27 ---> baec69296533 28Step 13/14 : EXPOSE 3000 29 ---> Running in 76cb5aed3e0b 30Removing intermediate container 76cb5aed3e0b 31 ---> 3912382d6f32 32Step 14/14 : CMD ["rails", "server", "-b", "0.0.0.0"] 33 ---> Running in 8f600fdf2090 34Removing intermediate container 8f600fdf2090 35 ---> a87608689898 36 37Successfully built a87608689898 38Successfully tagged books_web:latest 39

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

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

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

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

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

guest

回答1

0

database.yml に Compose ファイルの一部が混入しています:

diff

1default: &default 2 adapter: mysql2 3 encoding: utf8 4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 5 username: root 6 password: example 7 # socket: /tmp/mysql.sock 8- services: 9- db: 10- command: --default-authentication-plugin=mysql_native_password 11- restart: always 12- environment: 13- MYSQL_ROOT_PASSWORD: example 14- image: mysql 15 host: db 16 17development: 18 <<: *default 19 database: Books_development 20 21test: 22 <<: *default 23 database: Books_test 24 25production: 26 <<: *default 27 database: Books_production 28 29 username: root 30 password: <%= ENV['DATABASE_PASSWORD'] %> 31 # socket: /var/lib/mysql/mysql.sock

投稿2020/09/08 07:23

y_shinoda

総合スコア3272

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

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

tomsuma

2020/09/08 07:42

ご回答ありがとうございます! この記述を消したのでがエラー内容は変わりませんでした、、
tomsuma

2020/09/08 08:44

db_1 | 2020-09-08 08:43:52 1 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work. db_1 | 2020-09-08 08:43:52 1 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work. とりあえず全部消してやり直したら コレが出てきました
y_shinoda

2020/09/08 08:49

volume を消していないのではありませんか? 現在のデータベース内のデータが必要なければ、 volume を次のコマンドで完全に初期化できます: docker-compose down -v
tomsuma

2020/09/08 09:48

ありがとうございます! 消して改めてcompose up してみたところ エラーが出てきたので $ docker stop $(docker ps -q) $ docker rm $(docker ps -aq) $ docker rmi $(docker images -q) これらのコマンドを打ち、やり直したところ Retrying download gem from https://rubygems.org/ due to error (2/4): Gem::RemoteFetcher::UnknownHostError no such name (https://rubygems.org/gems/rails-dom-testing-2.0.3.gem) のようなエラーが出ました。(質問欄にも記入) このエラーが起きても問題なくbuildできたので先に進んでも良いのしょうか? また、最初の質問内容とかなり離れるので、このエラー 解決後一旦締めせてもらいます
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.47%

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

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

質問する

関連した質問