当前位置: 首页 > 知识库问答 >
问题:

安装 gcs 时出现 Docker 映像错误

羊舌源
2023-03-14

我正在尝试在GoogleKubernetes引擎中的docker映像中安装fuse。

这是我的多克文件:

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

但是当我尝试构建这个图像时,我得到了以下错误:

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

我试图在docker容器内的ubuntu映像上运行这个程序,以访问容器内的Google云存储。

我只想在我的容器内下载gcsfuse,我已经尝试了很多事情,最终都出现了错误,但这个错误似乎是最合理的错误,所以我问这个,但如果有更好的方法来下载保险丝,我也可以尝试一下。

我尝试了这里的解决方案,但没有用:

  • 吉特哈布问题
  • 堆栈溢出问题

我还尝试实现了这两个安装,它们导致了不同的错误消息。

编辑:当我尝试这样做时:


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

我收到此错误:

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

共有2个答案

管和志
2023-03-14

如果您在泊坞站文件中使用以下命令,它将解决将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/*
袁运良
2023-03-14

错误很有用:

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

您想要< code>0退出状态,这意味着命令成功。

然后,您可以通过尝试在容器中安装来确认|调试:

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

googlegcsfuse提供了在Linux安装的留档

您需要安装< code>gcsfuse的URL及其公钥,以便您可以< code>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 -
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"]
 类似资料:
  • 当我试图将包含一个简单的streamlit应用程序的Docker映像部署到Heroku时,我遇到了一些初期问题。我的问题是,部署后我无法访问我的Docker。经过仔细观察,我发现了以下错误: 错误R10(启动超时)- 我研究并了解到这是因为端口不可用,因为Heroku将动态分配端口号。 我在Dockerfile中添加了以下内容,以确保不会发生这种情况。 我现在可以看到网络URL和外部URL端口号是

  • 这是我第一次尝试创建Docker形象,我希望有人能帮助我。我的Dockerfile大致如下所示: 基本上,我只是为了扩展jar文件而安装Java。运行makefile时,出现以下错误: /bin/sh:1:/usr/lib/jvm/java-7-openjdk-amd64:权限被拒绝 我一直试图效仿这个例子:https://registry.hub.docker.com/u/barnybug/op

  • 我在安装NPM时遇到以下错误: npm WARN Worker-Loader@0.8.1需要WebPack@>=0.9<2^2.1.0-Beta^2.2.0的对等项,但未安装任何对等项。 npm警告可选跳过可选依赖项:fsevents@1.1.2(node_modules\fsevents): npm WARN notsup跳过可选依赖项:fsevents@1.1.2:wanted平台不受支持{“

  • 我是Docker的新手。我创建了以下Dockerfile并运行它: 来自Centos:最新的ENV container docker运行YUM-Y更新&&yum clean all 我收到以下错误/输出: root@ggnlabvm-juper6:~/docker_test#docker build-t test。 将构建上下文发送到Docker守护进程2.048 kB 步骤1/3:来自Cento

  • 所以我一直在寻找12个小时,现在这个错误的解决方案,我在尝试安装Laravel框架的PHP。我发现了许多不同的帖子,但似乎没有一个工作。这里的问题,我通过所有的步骤得到Laravel在我的电脑,这是下载和安装作曲家到我的 /usr/local/bin/目录,然后运行这个命令: 我得到这个错误: 我已经删除并重新安装了php,我已经运行了一个脚本,查看是否安装了mcrypt,它是否运行正确,我已经尝