1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

docker-conpose-upでpackage.jsonが見つからないエラー

Last updated at Posted at 2024-11-10

エラー内容

ERROR [service 4/6] COPY ./service/package.json ./
failed to solve: failed to compute cache key: failed to calculate checksum of ref d476e395-dc31-41e5-8a72-003e0f005629::om95zmtnkz48duec9643xj82m: "/service/package.json": not found

原因

ディレクトリ構造

project/
├── docker/
│   ├── web/
│   │   └── Dockerfile
│   └── service/
│       └── Dockerfile
├── service/
│   ├── package.json
│   ├── pnpm-lock.yaml
│   └── ...
└── web/
    └── ...
pnpm-workspace.yaml
build:
      context: ./
      dockerfile: web/Dockerfile

context: ./にしていることで、1個上の階層のserviceとwebのpackage.jsonにアクセスできないため見つからないというエラーになった
contextで指定したビルドコンテキストはdockerfile: web/Dockerfileのパス指定のときに使用するだけでなく、これ以降のスクリプトすべてに影響する。

ビルドコンテキストとは
Docker がイメージをビルドするときに利用するファイルやディレクトリの範囲

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?