0
0

More than 3 years have passed since last update.

dockerでカラムの変更ができないエラー

Last updated at Posted at 2020-03-30

docker-composeで自作アプリのテーブルをいじっていたらこんなエラーに遭遇しました。

$ docker-compose exec app rails g migration rename_star_column_to_topics
Starting sakelog_db_1 ... done
Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"rails\": executable file not found in $PATH": unknown

再起動してみたり、appをdbに書き換えてみたり、色々試しましたが解決できず。

でも解決法は意外と単純でした。

$ docker-compose exec app bundle exec rails g migration rename_star_column_to_topics
Starting sakelog_db_1 ... done
      invoke  active_record
      create    db/migrate/20200330013557_rename_star_column_to_topics.rb

railsの前に bundle execを付け足したらよかったんですね。

今までよくわからずに放置して使ってたbundle exec。
今回のエラーを経て改めて検索し直したら、
bundle execをつけずに実行すると、グローバルにインストールされているgemが動くのに対し、
bundle execをつけて実行するとプロジェクト内にあるgemが動くんだそうで。

なんとなくって怖いですね。適宜知識を増やしていかないと。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0