[Docker] What to do when error Couldn't find the binary git appears

error Couldn't find the binary git source code for Dockerfile

When I created a Docker image from an app developed with Nuxt.js, I got the error "** error Couldn't find the binary git **".

The source code of the Dockerfile where the error actually occurred is as follows.

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"]

Reference: https://qiita.com/arthur_foreign/items/fca369c1d9bde1701e38

Error log when creating Docker image

The error log looks like this: (I was supposed to push the image to 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

As you can see in the title and heading, you're getting the error ʻerror Couldn't find the binary git`.

error Couldn't find the binary git cause

Exactly the same error was posted on teratail.

Reference: https://teratail.com/questions/179483

It seems that Git is crazy to see the best answer and solution report of teratail.

error Couldn't find the binary git solution

Perhaps teratail is a local operation, so let's match it with the Dockerfile.

If it doesn't work with Docker, you need to put Git in ʻapk, the package manager for ʻalpine.

Therefore, let's make the Dockerfile as follows.

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"]

Then, the Docker image will be created successfully.

Successfully built xxxxxxxxxxxx
Successfully tagged gcr.io/gke_project_name/app_name:v1

Recommended Posts

[Docker] What to do when error Couldn't find the binary git appears
What to do when pyinstaller: error: argument --add-binary: invalid add_data_or_binary value: appears
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
What to do when "OS Error: [WinError 126] The specified module cannot be found" appears in import torch
What to do when "Type Error: must be _socket.socket, not socket" appears on GAE
What to do if you get the error ʻERR_FEATURE_UNAVAILABLE_ON_PLATFORM` when using ts-node-dev on Linux
What to do when a Remove Error occurs when updating conda
What to do when an error occurs with import _ssl
What to do when "SSL: CERTIFICATE_VERIFY_FAILED _ssl.c: 1056" appears in Python
OSError: [Errno 40] What to do when Message too long appears
What to do when "Invalid HTTP_HOST header" appears in Django
What to do when Ubuntu crashes
[AWS] What to do when the ping command causes a "timeout"
[Beanstalk] What to do when an error occurs with import uuid
What to do when the jupyterlab extension settings are not reflected
What to do if Insecure Platform Warning appears when running Python
What to do when you get "I can't see the site !!!!"
What to do when the value type is ambiguous in Python?
[Memorandum] What to do when a warning appears after executing pip list
What to do when the result downloaded via scrapy is in English
[Python] What to do when an error related to SSL authentication is returned
What to do if an error occurs when importing numpy with VScode
What to do if you get an error when trying to load mnist
What to do if you get an error when installing Dlib (Ubuntu)
[OSX] [pyenv] What to do when an SSL error occurs in pip
What to do when psycopg2 throws an error when pipenv lock under Pipenv environment
[Django] What to do if an Integrity Error occurs when registering data from the management site to the database
[python] What to do when an error occurs in send_keys of headless chrome
What to do when SSL error occurs in pip in Windows10, miniconda, VScode environment
What to do when a warning appears around Python integration in Neovim's CheckHealth
[Ubuntu 18.04 LTS] What to do when the screen resolution cannot be selected [NVIDIA]
What to do when "TypeError: data type not understood" appears in python's numpy.zeros
What to do if you get an error when installing python with pyenv
What to do when PermissionError of tempfile.mkstemp occurs
What to do when [Errno 2] No such file or directory appears in Python
What to do when the graph does not appear in jupyter (ipython) notebook
What to do if a version error occurs in the selenium Chrome driver
What to do if you get the error "Error: opencv3: Does not support building both Python 2 and 3 wrappers" when installing openCV 3
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
What to do if you get an OpenSSL error when installing Python 2 with pyenv
What to do when is not in the sudoers file.This incident will be reported.
What to do if you get a memory error when converting from PySparkDataFrame to PandasDataFrame
[Python] What to do when No module named'pyproj.datadir' appears when Exe is done with PyInstaller
What to do when only the window is displayed and nothing is displayed in pygame Note
What to do if the print command itself causes an error in Maya python
What to do if you get an error when importing matplotlib in Python (Mac)
What to do if you get an Import Error when importing matplotlib with Jupyter
curl: (60) What to do when Issuer certificate is invalid.
What to do when gdal_merge creates a huge file
What to do when raise ValueError, "unsupported hash type"
What to do when "cannot import name xxx" [Python]
What to do when you can't bind CaboCha to Python
What to do when you get an error saying "Name resolution temporarily failed" on linux
What to do if the image is not displayed using matplotlib etc. in the Docker container
What to do if you get an error when running "certbot renew" in CakePHP environment
What to do if you get an Undefined error when trying to use pip with pyenv
[AWS] What to do when you want to pip with Lambda
What to do if the package dependency cannot be repaired
What to do when PyCharm font is strange or garbled
What to do when Unalignable boolean Series provided as indexer
What to do if a 0xC0000005 error occurs in tf.train.start_queue_runners ()