我有一个 Docker 容器 19.10 作为主机和客户机,并且我尝试安装 gcloud:
# Add the Cloud SDK distribution URI as a package source
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# Fix the zany problem of user apt not being able to access a file from curl
# https://askubuntu.com/questions/908800/what-does-this-synaptic-error-message-mean
RUN chown -R _apt:root /var/lib/apt/lists
# Import the Google Cloud Platform public key
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
# Update the package list and install the Cloud SDK
RUN apt update && apt install -qy google-cloud-sdk
我收到以下错误:
Step 7/8 : RUN apt update && apt install -qy google-cloud-sdk
---> Running in c1e06f8c1130
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Get:1 http://packages.cloud.google.com/apt cloud-sdk InRelease [6343 B]
Get:2 http://packages.cloud.google.com/apt cloud-sdk/main amd64 Packages [108 kB]
Hit:3 http://archive.ubuntu.com/ubuntu eoan InRelease
Fetched 114 kB in 1s (185 kB/s)
Reading package lists...
Building dependency tree...
Reading state information...
All packages are up to date.
W: Download is performed unsandboxed as root as file '/var/lib/apt/lists/partial/archive.ubuntu.com_ubuntu_dists_eoan_InRelease' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
google-cloud-sdk : Depends: python2.7 but it is not installable
Recommends: python-crcmod but it is not installable
E: Unable to correct problems, you have held broken packages.
The command '/bin/sh -c apt update && apt install -qy google-cloud-sdk' returned a non-zero code: 100
make: *** [Makefile:4: build] Error 100
我该如何解决?
答案1
手动安装 Python2.7 解决了这个问题。但由于 Python2.7 不在此映像的默认存储库中,因此我必须添加它们。
在尝试安装 gcloud 之前添加以下几行解决了我的问题:
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ eoan universe" | tee -a /etc/apt/sources.list.d/python27.list
# Fix the zany problem of user apt not being able to access a file from curl
# https://askubuntu.com/questions/908800/what-does-this-synaptic-error-message-mean
RUN chown -R _apt:root /var/lib/apt/lists
RUN apt update
RUN apt install -qy curl git screen vim gnupg python2.7