Lorsque j'ai créé une image Docker à partir d'une application développée avec Nuxt.js, j'ai eu l'erreur «** error Couldn't find the binary git **».
Le code source du Dockerfile où l'erreur s'est réellement produite est le suivant.
FROM node:10.15.1-alpine as builder
WORKDIR /app
COPY . /app
RUN yarn install --production
RUN yarn build
FROM node:10.15.1-alpine
WORKDIR /app
COPY --from=builder /app /app
CMD ["yarn", "start"]
Référence: https://qiita.com/arthur_foreign/items/fca369c1d9bde1701e38
Le journal des erreurs ressemble à ceci: (Il était censé pousser l'image vers GCR)
$ docker build -t gcr.io/${PROJECT_ID}/app_name:v1 .
Sending build context to Docker daemon 157.9MB
Step 1/9 : FROM node:10.15.1-alpine as builder
---> xxxxxxxxxx
Step 2/9 : WORKDIR /app
---> Running in xxxxxxxxxx
Removing intermediate container 0eb38e4dfdc1
---> xxxxxxxxxx
Step 3/9 : COPY . /app
---> xxxxxxxxxx
Step 4/9 : RUN yarn install --production
---> Running in xxxxxxxxxx
yarn install v1.13.0
[1/4] Resolving packages...
[2/4] Fetching packages...
error Couldn't find the binary git
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
The command '/bin/sh -c yarn install --production' returned a non-zero code: 1
Comme vous pouvez le voir dans le titre et l'en-tête, vous obtenez l'erreur ʻerror Couldn't find the binary git`.
Exactement la même erreur a été publiée sur teratail.
Référence: https://teratail.com/questions/179483
Il semble que Git soit fou de voir la meilleure réponse et le meilleur rapport de solution de teratail.
Peut-être que teratail est une opération locale, alors faisons-le correspondre au Dockerfile.
Si cela ne fonctionne pas avec Docker, vous devez mettre Git dans ʻapk, le gestionnaire de paquets pour ʻalpine.
Par conséquent, créons le Dockerfile comme suit.
FROM node:10.15.1-alpine as builder
WORKDIR /app
COPY . /app
RUN apk update && \
apk add git
RUN yarn install --production
RUN yarn build
FROM node:10.15.1-alpine
WORKDIR /app
COPY --from=builder /app /app
CMD ["yarn", "start"]
Ensuite, l'image Docker est créée avec succès.
Successfully built xxxxxxxxxxxx
Successfully tagged gcr.io/gke_project_name/app_name:v1
Recommended Posts