LoginSignup
4
4

More than 3 years have passed since last update.

docker-compose upでコンテナが立ち上がらずエラーが出たときの話

Posted at

前日まで使えていたのに、ある日いきなりdockerが立ち上がらなくなった。(PCアップデートしたせい??)

最初にでたのはこんな感じのエラー

 Could not find ancestry-3.1.0 in any of the sources
 Run `bundle install` to install missing gems.

上記のgemはgemfile.lockに載っているし、エラーが出るのはおかしいと思いつつもdocker-compose run web bundle installしてみたけど案の定同じエラーで動かない。

検索してみるとこんな記事があった。
https://teratail.com/questions/291124
試しにdocker-compose build --no-cacheをやってみると次は以下のエラーが

db uses an image, skipping
Building web
Traceback (most recent call last):
  File "site-packages\docker\utils\build.py", line 96, in create_archive
OSError: [Errno 22] Invalid argument: '\\ディレクトリ名\\¥アプリ名\\node_modules\\.bin\\acorn'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose\cli\main.py", line 67, in main
  File "compose\cli\main.py", line 126, in perform_command
  File "compose\cli\main.py", line 302, in build
  File "compose\project.py", line 468, in build
  File "compose\project.py", line 450, in build_service
  File "compose\service.py", line 1125, in build
  File "site-packages\docker\api\build.py", line 160, in build
  File "site-packages\docker\utils\build.py", line 31, in tar
  File "site-packages\docker\utils\build.py", line 100, in create_archive
OSError: Can not read file in context: \\?\ディレクトリ名\アプリ名\node_modules\.bin\acorn
[24060] Failed to execute script docker-compose

上記のエラーで調べてみると、この記事にたどり着いた。
https://crieit.net/posts/docker-compose-build-Can-not-read-file
記載されている通り、.dockerignoreを作成しnode_modulesと記載すればdocker-compose buildが動くように!

エラーで検索した際にdockerのバージョンの問題という記事も見つけたのですが、自分のバージョンと違うようだったので謎が深まりました...無事解決してよかったです。
https://github.com/docker/compose/issues/5888

今回エラーが起きたバージョン

docker-compose version 1.27.4, build 40524192
Docker version Version:  19.03.13
4
4
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
4
4