1

I'm trying to install fuse to my docker image that's inside Google Kubernetes Engine.

Here is my 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.

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.

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
Turgut
  • 711
  • 3
  • 25

2 Answers2

2

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.

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

You need to install gcsfuse's URL and its public key so that you can apt install it.

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"]
DazWilkin
  • 32,823
  • 5
  • 47
  • 88
  • 1
    When i try to run it like that i get this error: ```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``` – Turgut Aug 07 '22 at 15:25
  • 1
    There seems to be a problem with gcsfuse.list; any suggestions here ? Just a note: This does not work with Dockerfile only. – london_utku Aug 07 '22 at 15:37
  • 2
    Yes, you're correct. The container image appears to not include `lsb_release` and so the trio of setup commands, fail. Can you try running the `ubuntu:22.10` container locally to test... `apt install lsb-core` and then (!) `export GCSFUSE_REPO=gcsfuse-$(lsb_release -c -s)` etc. Without `lsb_release` `GCSFUSE_REPO` incorrectly (!) equals `gcsfuse-` (without a release) and thus the `gcsfuse.list` misses the value too. – DazWilkin Aug 07 '22 at 16:02
  • 1
    That is what we get : E: Unable to locate package lsb-core The command '/bin/sh -c apt install lsb-core' returned a non-zero code: 100 ERROR ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 100 – london_utku Aug 07 '22 at 16:20
  • 2
    You'll need to `apt update` before you try `apt install lsb-core` – DazWilkin Aug 07 '22 at 16:37
  • 1
    Now trying - RUN apt update && apt install lsb-release – london_utku Aug 07 '22 at 16:40
  • 1
    Still getting this --- 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 ERROR ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 100 – london_utku Aug 07 '22 at 16:42
  • 1
    When i add these lines: ```RUN apt-get update -y && apt-get -y install lsb-release curl gnupg && apt install lsb-core RUN lsb_release -c -s``` We are getting this error: ``` ... Err:2 http://packages.cloud.google.com/apt gcsfuse-kinetic Release 404 Not Found [IP: 173.194.217.139 80] ...Reading package lists... E: The repository 'http://packages.cloud.google.com/apt gcsfuse-kinetic Release' does not have a Release file.``` – Turgut Aug 07 '22 at 17:09
  • 2
    Ah.... I think Kinetic isn't supported. Try Focal (20:04) – DazWilkin Aug 07 '22 at 17:38
  • 1
    Do you mean instead of using FROM --platform=amd64 ubuntu:22.10 , shall we use FROM ubuntu:20.04 ? – london_utku Aug 07 '22 at 17:40
  • I think so. See the [`install`](https://github.com/GoogleCloudPlatform/gcsfuse/blob/master/docs/installing.md#ubuntu-and-debian-latest-releases) it doesn't include Kinetic (22.10) but does include Focal (20.04) ([releases](https://wiki.ubuntu.com/Releases)) – DazWilkin Aug 07 '22 at 18:03
  • You may then have issues with `tzdata` prompting for Geos. I just tried this. You'll want to consider something like `DEBIAN_FRONTEND=noninteractive TZ=Americas/Los_Angeles apt install -y tzdata` before installing `lsb-core` so that the container builds without pausing. – DazWilkin Aug 07 '22 at 18:04
1

For anyone still facing this issue. The problem was that in the Dockerfile, using RUN export doesn't actually export the variable. This fixed it:

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

# Install GCSFuse
RUN echo "deb https://packages.cloud.google.com/apt gcsfuse-$(lsb_release -c -s) 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 update
RUN yes | apt-get install fuse gcsfuse
pk2301
  • 11
  • 1