LoginSignup
0
1

More than 3 years have passed since last update.

Dockerでgccエラーが出た時の対処方法

Posted at

概要

google-cloud-bigqueryの最新バージョンをpython*alpineの最新版に入れようとしたら下記のようなエラーが出てインストールに失敗しました最終的に修正後のDockerfileのようにしたところ無事インストールできました。

修正前のDockerfile

Dockerfile
FROM python:3.9.0-alpine3.12

RUN apk --update add \
    curl \
    bash

RUN apk --update add tzdata && \
    cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

COPY ./requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
RUN curl -sSL https://sdk.cloud.google.com | bash
ENV PATH $PATH:/root/google-cloud-sdk/bin

RUN mkdir -p /src

FROM python:3.9.0-alpine3.12

RUN apk --update add \
    curl \
    gcc \
    musl-dev \
    linux-headers \
    build-base \
    libffi-dev \
    bash

RUN apk --update add tzdata && \
    cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

COPY ./requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
RUN curl -sSL https://sdk.cloud.google.com | bash
ENV PATH $PATH:/root/google-cloud-sdk/bin
  • エラー1
error: command 'gcc' failed: No such file or directory
  • エラー2
fatal error: limits.h: No such file or directory
  • エラー3
fatal error: ffi.h: No such file or directory
requirements.txt
google-cloud-bigquery==2.4.0

修正後のDockerfile

Dockerfile
FROM python:3.9.0-alpine3.12

RUN apk --update add \
    curl \
    gcc \
    musl-dev \
    linux-headers \
    build-base \
    libffi-dev \
    bash

RUN apk --update add tzdata && \
    cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

COPY ./requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
RUN curl -sSL https://sdk.cloud.google.com | bash
ENV PATH $PATH:/root/google-cloud-sdk/bin

RUN mkdir -p /src

FROM python:3.9.0-alpine3.12

RUN apk --update add \
    curl \
    gcc \
    musl-dev \
    linux-headers \
    build-base \
    libffi-dev \
    bash

RUN apk --update add tzdata && \
    cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

COPY ./requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
RUN curl -sSL https://sdk.cloud.google.com | bash
ENV PATH $PATH:/root/google-cloud-sdk/bin


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