Home>

docker-compose run web rails db: want to create

Please write the details of your question here.
This is an error that occurred when docker was installed after deploying with EC2 on AWS to an application created with rails.

Mysql2 :: Error :: ConnectionError: Plugin caching_sha2_password could not be loaded: /usr/lib/x86_64-linux-gnu/mariadb19/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
Corresponding source code

Dockerfile

FROM ruby: 2.6.5
RUN apt-get update -qq&&\
    apt-get install -y build-essential \
                       libpq-dev \
                       nodejs
RUN mkdir/app_name
ENV APP_ROOT/app_name
WORKDIR $APP_ROOT
ADD ./Gemfile $APP_ROOT/Gemfile
ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock
RUN gem install bundler
RUN bundle install
ADD. $APP_ROOT


docker-compose.yml

version: '3'
services: services:
  db:
    image: mysql: 8.0.21
    environment: environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: root
    ports: ports:
      -"4306: 3306"
    volumes:
      --./mysql-confd:/etc/mysql/conf.d

  web:
    build: ..
    command: rails s -p 3000 -b '0.0.0.0'
    volumes:
      --.:/App_name
    ports: ports:
      -"3000: 3000"
    links: links:
      --db


database.yml

default:&default
  adapter: mysql2
  encoding: utf8
  pool:<% = ENV.fetch ("RAILS_MAX_THREADS") {5}%>
  username: root
  password: password
  socket: /tmp/mysql.sock
  host: db
development:
<<: * default
  database: errors_original_app_development
test: test:
<<: * default
  database: errors_original_app_test
production:
<<: * default
  adapter: mysql2
  encoding: utf8
  pool:<% = ENV.fetch ("RAILS_MAX_THREADS") {5}%>
  username: root
  password: password:
  socket: /tmp/mysql.sock
  username: root
  database: errors_original_app_production
  password:<% = ENV ['DATABASE_PASSWORD']%>
  socket: /var/lib/mysql/mysql.sock
What I tried

-Erase all images and rebuild the container

· Local mysql-confd/default_authentication.cnf

[mysqld]
default_authentication_plugin = mysql_native_password


Insert

Supplementary information (FW/tool version, etc.)

ruby 2.6.5
rails 6.0.3.4
mysql 8.0.21
docker 19.03.13

  • Answer # 1

    https://taker.hatenablog.com/entry/2019/10/19/152007
    I was able to solve it by referring to the above article