1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Docker】failed to solve: failed to compute cache key: "/Gemfile" not found: not foundの対処方法

Posted at

症状

RailsのImageをpullして、docker-compose runを実施しようとしたとき、下記のエラーメッセージが表示されました。 下記のサイトの手順で実施。

翻訳すると、「キャッシュキーの計算に失敗しました: "/ Gemfile"が見つかりません:見つかりません」でした。
Gemfileが見つからない。といっていますね

error
docker-compose run web rails new . --force --database=postgresql
[+] Running 1/0
 - Container dockerapp-db-1  Created                                                                               0.0s
[+] Running 1/1
 - Container dockerapp-db-1  Started                                                                               0.9s
[+] Building 3.2s (9/12)
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 269B                                                                               0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load metadata for docker.io/library/ruby:2.3.3                                                      3.1s
 => CANCELED [1/8] FROM docker.io/library/ruby:2.3.3@sha256:fb643a7188c7567d5e32b47d674a32589df86bec769b5fef97895  0.0s
 => => resolve docker.io/library/ruby:2.3.3@sha256:fb643a7188c7567d5e32b47d674a32589df86bec769b5fef978951aa3efe99  0.0s
 => => sha256:0e1db669d557d1137824b523e53ee2238eb6189aacb67b3e5581f09acdf126df 7.16kB / 7.16kB                     0.0s
 => => sha256:fb643a7188c7567d5e32b47d674a32589df86bec769b5fef978951aa3efe994d 2.00kB / 2.00kB                     0.0s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 655B                                                                                  0.0s
 => CACHED [2/8] RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs                     0.0s
 => CACHED [3/8] RUN mkdir /myapp                                                                                  0.0s
 => CACHED [4/8] WORKDIR /myapp                                                                                    0.0s
 => ERROR [5/8] ADD Gemfile /myapp/Gemfile                                                                         0.0s
------
 > [5/8] ADD Gemfile /myapp/Gemfile:
------
failed to solve: failed to compute cache key: "/Gemfile" not found: not found

ファイル名は下記です。

image.png

Doclerfile
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /myapp
WORKDIR /myapp
ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
ADD . /myapp

解決策

ファイル名を「GemFile」から「Gemfileに変更することで解決しました。 原因としては、DockerfileではGemfileと書いていたのに、実際にはGemFileとなっていたため、ファイルが見つからないというエラーが出ていたようです。

image.png

参考

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?