52980
質問です。

[DockerでRails +
MySQLの開発環境をつくる手順](https://qiita.com/jshimazu/items/ba13ce87dfdb11e2d1d9)  
[Quickstart: Compose and Rails](https://docs.docker.com/compose/rails/)  
を見てここでも色々教えていただき

GCPでもdocker-composeできましたが

`docker-compose run web rake db:create`

`docker-compose run web bin/rails g scaffold User name:string`

`docker-compose run web bundle exec rails db:migrate`

の最後をしたところ

```

    Creating network "root_default" with the default driver
    Creating root_db_1 ...
    Creating root_db_1 ... done
    rake aborted!
    Mysql2::Error: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
    /usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:89:in `connect'
    /usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:89:in `initialize'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/mysql2_adapter.rb:21:in `new'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/mysql2_adapter.rb:21:in `mysql2_connection'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:88:in `connection'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/schema_migration.rb:20:in `table_exists?'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/schema_migration.rb:24:in `create_table'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:1125:in `initialize'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:1007:in `new'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:1007:in `up'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:985:in `migrate'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
    /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
    /usr/local/bundle/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
    Tasks: TOP => db:migrate
    (See full trace by running task with --trace)
    
```

のエラーがでるのですが....  
最後の部分教えてください。  
よろしくお願いします。
CC BY-SA 4.0
2019-02-22T10:29:38.523
52946
2019-02-25T15:13:32.377
2019-02-25T15:13:32.377
19329
19329
question
ruby-on-rails docker docker-compose
docker-compose run web bundle exec rails db:migrateエラー
GCP上に下記の順番で実施した所、エラーも無く生成できました。  
また、MAC上にも同様に生成できました。

  1. GCPのインスタンス生成
  2. docker,docker-composeのインストール。
  3. [DockerでRails + MySQLの開発環境をつくる手順](https://qiita.com/jshimazu/items/ba13ce87dfdb11e2d1d9)を順番に実施。
  4. port 3000のfirewallの設定
CC BY-SA 4.0
2019-02-23T19:46:21.627
52980
2019-02-23T19:46:21.627
32285
52946
answer
```

    version: '3'
    services:
      db:
        image: mysql:5.7
        environment:
          MYSQL_USER: root
          MYSQL_ROOT_PASSWORD: password
        ports:
          - '3316:3306'
        volumes:
          - ./db/mysql/volumes:/var/lib/mysql
    
      web:
        build: .
        command: bundle exec rails s -p 3000 -b '0.0.0.0'
        volumes:
          - .:/myapp
        ports:
          - "3000:3000"
        depends_on:
          - db
    
```

で直りました。  
ありがとうございました。
CC BY-SA 4.0
2019-02-25T15:13:06.873
53034
2019-02-25T15:13:06.873
19329
52946
answer