docker / getting-started-todo-app

Sample application to get started with Docker
Apache License 2.0
31 stars 128 forks source link

[Bug] ERROR [backend backend-dev 2/4] RUN --mount=type=cache,id=yarn,target=/usr/local/share/.cache/yarn yarn install --frozen-lockfile #34

Open S-AQ opened 1 month ago

S-AQ commented 1 month ago

I just started the tutorial and bumped straight into an error.

After I cloned the repository and ran docker compose watch from the getting-started-todo-app-directory, the container did not run and I was confronted with the following output:

[+] Running 36/3
 ✔ phpmyadmin Pulled                                                                                                                                                                                                                                                                            12.5s 
 ✔ mysql Pulled                                                                                                                                                                                                                                                                                 16.7s 
 ✔ proxy Pulled                                                                                                                                                                                                                                                                                  5.8s 
[+] Building 24.3s (14/19)                                                                                                                                                                                                                                                       docker:desktop-linux
 => [backend internal] load build definition from Dockerfile                                                                                                                                                                                                                                     0.1s
 => => transferring dockerfile: 3.39kB                                                                                                                                                                                                                                                           0.0s 
 => [client internal] load build definition from Dockerfile                                                                                                                                                                                                                                      0.1s 
 => => transferring dockerfile: 3.39kB                                                                                                                                                                                                                                                           0.0s 
 => [client internal] load metadata for docker.io/library/node:20                                                                                                                                                                                                                                1.7s 
 => [client auth] library/node:pull token for registry-1.docker.io                                                                                                                                                                                                                               0.0s
 => [backend internal] load .dockerignore                                                                                                                                                                                                                                                        0.0s
 => => transferring context: 52B                                                                                                                                                                                                                                                                 0.0s 
 => [client internal] load .dockerignore                                                                                                                                                                                                                                                         0.0s 
 => => transferring context: 52B                                                                                                                                                                                                                                                                 0.0s 
 => [backend base 1/2] FROM docker.io/library/node:20@sha256:fffa89e023a3351904c04284029105d9e2ac7020886d683775a298569591e5bb                                                                                                                                                                   16.8s 
 => => resolve docker.io/library/node:20@sha256:fffa89e023a3351904c04284029105d9e2ac7020886d683775a298569591e5bb                                                                                                                                                                                 0.0s 
 => => sha256:fffa89e023a3351904c04284029105d9e2ac7020886d683775a298569591e5bb 6.41kB / 6.41kB                                                                                                                                                                                                   0.0s 
 => => sha256:cdd62bf39133c498a16f7a7b1b6555ba43d02b2511c508fa4c0a9b1975ffe20e 49.56MB / 49.56MB                                                                                                                                                                                                 3.2s 
 => => sha256:a47cff7f31e941e78bf63ca19f0811b675283e2c00ddea10c57f78d93b2bc343 24.05MB / 24.05MB                                                                                                                                                                                                 2.7s 
 => => sha256:979b917260c5ac04146dd0f21f2a820ce14084ed54012498a87ebcaf4c128e64 2.49kB / 2.49kB                                                                                                                                                                                                   0.0s 
 => => sha256:ef970e331526a3ccb44f8915cc0f1cc0265e6b2b4418f380e369618faa117f75 6.51kB / 6.51kB                                                                                                                                                                                                   0.0s 
 => => sha256:a173f2aee8e962ea19db1e418ae84a0c9f71480b51f768a19332dfa83d7722a5 64.39MB / 64.39MB                                                                                                                                                                                                 5.9s 
 => => sha256:01272fe8adbacc44afd2b92994b31c40a151f4324ca392050d9e8d580927dd32 211.27MB / 211.27MB                                                                                                                                                                                              10.0s 
 => => sha256:69752a170a9cd7718768d71ae627b34ce2b63e0b0f1b21ba345f0f665ed46e14 3.33kB / 3.33kB                                                                                                                                                                                                   3.4s
 => => extracting sha256:cdd62bf39133c498a16f7a7b1b6555ba43d02b2511c508fa4c0a9b1975ffe20e                                                                                                                                                                                                        1.4s 
 => => sha256:6986256fa1607627a696c196c33290f4f96f88a1b0a41275327a2f69612bbed5 48.22MB / 48.22MB                                                                                                                                                                                                 6.8s 
 => => extracting sha256:a47cff7f31e941e78bf63ca19f0811b675283e2c00ddea10c57f78d93b2bc343                                                                                                                                                                                                        0.4s 
 => => extracting sha256:a173f2aee8e962ea19db1e418ae84a0c9f71480b51f768a19332dfa83d7722a5                                                                                                                                                                                                        2.1s 
 => => sha256:894ebdcee85de9bf6daf452b243b65a082986d7865d984ec080c81f01e7bff53 1.25MB / 1.25MB                                                                                                                                                                                                   6.2s 
 => => sha256:4163bcd94ffee8c075555d4a8d9531bce8f7fd572e00d4326a8ff15409ea7e04 448B / 448B                                                                                                                                                                                                       6.3s 
 => => extracting sha256:01272fe8adbacc44afd2b92994b31c40a151f4324ca392050d9e8d580927dd32                                                                                                                                                                                                        4.8s 
 => => extracting sha256:69752a170a9cd7718768d71ae627b34ce2b63e0b0f1b21ba345f0f665ed46e14                                                                                                                                                                                                        0.0s 
 => => extracting sha256:6986256fa1607627a696c196c33290f4f96f88a1b0a41275327a2f69612bbed5                                                                                                                                                                                                        1.3s 
 => => extracting sha256:894ebdcee85de9bf6daf452b243b65a082986d7865d984ec080c81f01e7bff53                                                                                                                                                                                                        0.0s 
 => => extracting sha256:4163bcd94ffee8c075555d4a8d9531bce8f7fd572e00d4326a8ff15409ea7e04                                                                                                                                                                                                        0.0s 
 => [backend internal] load build context                                                                                                                                                                                                                                                        0.0s 
 => => transferring context: 176.35kB                                                                                                                                                                                                                                                            0.0s 
 => [client internal] load build context                                                                                                                                                                                                                                                         0.0s 
 => => transferring context: 134.92kB                                                                                                                                                                                                                                                            0.0s 
 => [backend base 2/2] WORKDIR /usr/local/app                                                                                                                                                                                                                                                    0.9s 
 => [client client-base 1/5] COPY client/package.json client/yarn.lock ./                                                                                                                                                                                                                        0.1s 
 => [backend backend-dev 1/4] COPY backend/package.json backend/yarn.lock ./                                                                                                                                                                                                                     0.1s 
 => CANCELED [client client-base 2/5] RUN --mount=type=cache,id=yarn,target=/usr/local/share/.cache/yarn     yarn install                                                                                                                                                                        4.8s 
 => ERROR [backend backend-dev 2/4] RUN --mount=type=cache,id=yarn,target=/usr/local/share/.cache/yarn     yarn install --frozen-lockfile                                                                                                                                                        4.7s 
------
 > [backend backend-dev 2/4] RUN --mount=type=cache,id=yarn,target=/usr/local/share/.cache/yarn     yarn install --frozen-lockfile:
0.506 yarn install v1.22.22
0.513 warning package.json: No license field
0.534 warning backend@1.0.0: No license field
0.535 [1/4] Resolving packages...
0.613 [2/4] Fetching packages...
4.465 error https://registry.yarnpkg.com/prettier/-/prettier-3.2.4.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT: no such file or directory, stat '/usr/local/share/.cache/yarn/v6/npm-prettier-3.2.4-4723cadeac2ce7c9227de758e5ff9b14e075f283-integrity/node_modules/prettier/plugins/typescript.mjs'"
4.466 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------

After trying this, I tried docker compose up -d and that did work. But why does the tutorial say docker compose watch while it doesn't work?

igorkang-smc commented 1 month ago

Got same issue

thisistonydang commented 1 month ago

I just had the same issue. I tried deleting all my containers and reran docker compose watch and everything works now. Not sure why. 🤷

mikesir87 commented 3 weeks ago

Hi all! This is a sporadic error that occurs when the yarn install fails (which can be for a variety of reasons). Since the yarn cache directory is also cached by the builder, the error persists across builds. Currently, there are only two fixes available:

1) In the Dockerfile, update the RUN statement with the yarn install command to also run yarn cache clean. Run it through one time to get the build working again and then remove the cache clean (so it doesn't wipe the cache each time you build).

or

2) Update the RUN statement to remove the --mount... config, which will remove the cache mount. With that gone, the failed build won't carry through to following builds. The tradeoff is future builds will have to redownload all dependencies, rather than only what changed. But, for this project, that shouldn't be a big deal.

I'll start a conversation internally, as we may end up just going with Option 2 here and update the project for everyone. It hasn't affected too many people, but it is tricky to resolve when it comes up.

yatinburhmi commented 3 weeks ago

Hi all, If you are facing this issue try to run this command docker compose up --watch instead of docker compose watch, it worked for me.

IntelliLab2024 commented 2 weeks ago

docker compose up --watch worked for me but the page in browser is stuck in loading. docker compose up -d worked for me and it loaded properly in the browser. but maybe the --watch is not working, will check that. tks

yatinburhmi commented 2 weeks ago

@IntelliLab2024 are you trying to access to some port? because according to readme.md , navigate to http://localhost