简体   繁体   English

安装 gcsfuse 时出现 Docker 图像错误

[英]Docker image error while installing gcsfuse

I'm trying to install fuse to my docker image that's inside Google Kubernetes Engine.我正在尝试将保险丝安装到 Google Kubernetes 引擎内的 docker 图像中。

Here is my Dockerfile:这是我的 Dockerfile:

FROM --platform=amd64 ubuntu:22.10

# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]

# Install.
EXPOSE 80

RUN ls -la

RUN \
  sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
  apt-get update && \
  apt-get -y upgrade && \
  apt-get install -y build-essential && \
  apt-get install -y gcc && \
  apt-get install -y software-properties-common && \
  apt-get install -y cmake && \
  apt-get install -y make && \
  apt-get install -y clang && \
  apt-get install -y mesa-common-dev && \
  apt-get install -y git && \
  apt-get install -y xorg-dev && \
  apt-get install -y nasm && \
  apt-get install -y byobu curl git htop man unzip vim wget && \
  rm -rf /var/lib/apt/lists/* 

# RUN apt-get install -y gobjc++

#RUN apt-get install -y gnupg lsb-release wget
#RUN export DOCKER_DEFAULT_PLATFORM=linux/amd64
#RUN lsb_release -c -s > /tmp/lsb_release
#RUN GCSFUSE_REPO=$(cat /tmp/lsb_release); echo "deb http://packages.cloud.google.com/apt gcsfuse-$GCSFUSE_REPO main" | tee /etc/apt/sources.list.d/gcsfuse.list
#RUN wget -O - https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

RUN apt-get install --yes --no-install-recommends ca-certificates curl gpg gpg-agent
RUN echo "deb http://packages.cloud.google.com/apt gcsfuse-buster main" | tee /etc/apt/sources.list.d/gcsfuse.list 
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - 

RUN apt-get install -y gcsfuse

But when i try to build this image i get this following error:但是当我尝试构建此图像时,我收到以下错误:

Step 7/23 : RUN echo "deb http://packages.cloud.google.com/apt gcsfuse-buster main" | tee /etc/apt/sources.list.d/gcsfuse.list
 ---> Running in c027599dc506
deb http://packages.cloud.google.com/apt gcsfuse-buster main
Removing intermediate container c027599dc506
 ---> 732f7fb73280
Step 8/23 : RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
 ---> Running in 47ad78e4351e
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).

100  2537  100  2537    0     0  48417      0 --:--:-- --:--:-- --:--:-- 48788
OK
Removing intermediate container 47ad78e4351e
 ---> 90819264fc33
Step 9/23 : RUN apt-get install -y gcsfuse
 ---> Running in 8805b3fcaae8
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package gcsfuse
The command '/bin/sh -c apt-get install -y gcsfuse' returned a non-zero code: 100

I'm trying to run this on an ubuntu image inside my docker container to access the Google Cloud Storage inside my container.我正在尝试在我的 docker 容器内的 ubuntu 映像上运行它,以访问我容器内的 Google Cloud Storage。

I just want to download gcsfuse inside my container, I've tried many things which all ended up with an error but this error seems the most plausible one so I'm asking this one, but if there is a better way to download fuse I could also try that.我只想在我的容器中下载 gcsfuse,我尝试了很多事情,但都以错误告终,但这个错误似乎是最合理的,所以我问这个,但如果有更好的方法来下载 fuse 我也可以试试。

I tried the solutions here to no avail:我在这里尝试了解决方案无济于事:

I've also tried to implement These two instalations which resulted in different error messages.我还尝试实现这两个导致不同错误消息的安装。

Edit: When i try doing it like this:编辑:当我尝试这样做时:


RUN export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`

RUN echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" \
| tee /etc/apt/sources.list.d/gcsfuse.list

RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
| apt-key add -

RUN apt-get install -y gcsfuse

I get this error:我收到此错误:

Step 5/30 : RUN export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`
 ---> Running in 94ee52e0b35f
Removing intermediate container 94ee52e0b35f
 ---> fa5a33fd2305
Step 6/30 : RUN echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | tee /etc/apt/sources.list.d/gcsfuse.list
 ---> Running in 785cfe4c4d4c
deb http://packages.cloud.google.com/apt  main
Removing intermediate container 785cfe4c4d4c
 ---> f4aaed9a03ae
Step 7/30 : RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
 ---> Running in 8ccfdfab4681
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  2537  100  2537    0     0  24924      0 --:--:-- --:--:-- --:--:-- 25118
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK
Removing intermediate container 8ccfdfab4681
 ---> 9a856aa4bd1a
Step 8/30 : RUN apt-get install -y gcsfuse
 ---> Running in e4e0445ae72f
E: Malformed entry 1 in list file /etc/apt/sources.list.d/gcsfuse.list (Component)
E: The list of sources could not be read.
The command '/bin/sh -c apt-get install -y gcsfuse' returned a non-zero code: 100

The error is useful:该错误很有用:

apt-get install -y gcsfuse ... returned a non-zero error code

You want 0 exit status which means the command succeeeded.您想要0退出状态,这意味着命令成功。

You can then confirm|debug this by trying to install in a container:然后,您可以通过尝试在容器中安装来确认|调试:

docker run \
--interactive --tty --rm \
ubuntu:22.10 \
  apt install gcsfuse
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package gcsfuse

Googling gcsfuse provides documentation for install on Linux谷歌搜索gcsfuse提供了在 Linux 上安装的文档

You need to install gcsfuse 's URL and its public key so that you can apt install it.您需要安装gcsfuse的 URL 及其公钥,以便您可以apt install它。

export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`

echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" \
| sudo tee /etc/apt/sources.list.d/gcsfuse.list

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
| sudo apt-key add -
Update更新
FROM --platform=amd64 ubuntu:20.04

RUN apt update && \
    DEBIAN_FRONTEND=noninteractive \
    TZ=Americas/Los_Angeles \
    apt install -y curl lsb-core

RUN export GCSFUSE_REPO=gcsfuse-$(lsb_release -c -s) && \
    echo ${GCSFUSE_REPO} && \
    ( echo "deb http://packages.cloud.google.com/apt ${GCSFUSE_REPO} main" \
      | tee /etc/apt/sources.list.d/gcsfuse.list ) && \
    more /etc/apt/sources.list.d/gcsfuse.list && \
    ( curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
      | apt-key add - )

RUN apt update && apt -y install gcsfuse

ENTRYPOINT ["gcsfuse"]
CMD ["--help"]

If you use the following in your dockerfile, it will solve your issues with installing gcsfuse to your gke container:如果您在 dockerfile 中使用以下内容,它将解决您将 gcsfuse 安装到 gke 容器的问题:

ENV GCSFUSE_REPO gcsfuse-stretch
ENV GOOGLE_APPLICATIONS_CREDENTIALS=test-serviceaccount.json
ENV GCS_BUCKET: "my-bucket"
ENV GCS_BUCKET_FOLDER: "shared-data"

USER root

# Add google repositories for gcsfuse and google cloud sdk
RUN apt-get update -y && apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl gnupg
RUN echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | tee /etc/apt/sources.list.d/gcsfuse.list
RUN echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

# Install gcsfuse and google cloud sdk
RUN apt-get update -y  && apt-get install -y gcsfuse google-cloud-sdk \
    && apt-get autoremove -y \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM