gpt4 book ai didi

git - Docker 无法在 Ubuntu 容器上安装 git

转载 作者:行者123 更新时间:2023-12-04 13:08:57 28 4
gpt4 key购买 nike

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为 on-topic对于堆栈溢出。


去年关闭。







Improve this question




我有一个使用 ubuntu:21.04 的 Docker 镜像.当我通过 SSH 连接它时,我尝试安装 git using the official Git Ubuntu installation instructions但我收到一个错误:

root@c812b171354a:/home/ubuntu# sudo apt install git-all
bash: sudo: command not found
我很惊讶地看到 sudo不存在!所以我尝试不使用 sudo :
root@c812b171354a:/home/ubuntu# apt install git-all
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package git-all
所以我问: 我可以运行什么命令来安装 git在 Dockerized Ubuntu 21.04 容器上?
更新
这是我的完整 Dockerfile:
FROM ubuntu:21.04

COPY keep-alive.sh /home/ubuntu/keep-alive.sh

# give keep-alive script permission to run
RUN ["chmod", "+x", "/home/ubuntu/keep-alive.sh"]

# install git
RUN apt update -y
RUN apt install -y gpgv2 git-all

CMD ["/bin/bash", "-c", "/home/ubuntu/keep-alive.sh"]
当我构建图像时:
docker build -t myorg/linux-worker .
我得到:
Sending build context to Docker daemon   7.68kB
Step 1/6 : FROM ubuntu:21.04
---> 478aa0080b60
Step 2/6 : COPY keep-alive.sh /home/ubuntu/keep-alive.sh
---> Using cache
---> e1bcc0d7dd20
Step 3/6 : RUN ["chmod", "+x", "/home/ubuntu/keep-alive.sh"]
---> Using cache
---> ef46c36ec41b
Step 4/6 : RUN apt update -y
---> Running in fee517c02852

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Get:1 http://security.ubuntu.com/ubuntu hirsute-security InRelease [101 kB]
Err:1 http://security.ubuntu.com/ubuntu hirsute-security InRelease
gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Get:2 http://archive.ubuntu.com/ubuntu hirsute InRelease [269 kB]
Err:2 http://archive.ubuntu.com/ubuntu hirsute InRelease
gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Get:3 http://archive.ubuntu.com/ubuntu hirsute-updates InRelease [109 kB]
Err:3 http://archive.ubuntu.com/ubuntu hirsute-updates InRelease
gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Get:4 http://archive.ubuntu.com/ubuntu hirsute-backports InRelease [90.7 kB]
Err:4 http://archive.ubuntu.com/ubuntu hirsute-backports InRelease
gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Reading package lists...
W: GPG error: http://security.ubuntu.com/ubuntu hirsute-security InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://security.ubuntu.com/ubuntu hirsute-security InRelease' is not signed.
W: GPG error: http://archive.ubuntu.com/ubuntu hirsute InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://archive.ubuntu.com/ubuntu hirsute InRelease' is not signed.
W: GPG error: http://archive.ubuntu.com/ubuntu hirsute-updates InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://archive.ubuntu.com/ubuntu hirsute-updates InRelease' is not signed.
W: GPG error: http://archive.ubuntu.com/ubuntu hirsute-backports InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://archive.ubuntu.com/ubuntu hirsute-backports InRelease' is not signed.
The command '/bin/sh -c apt update -y' returned a non-zero code: 100
我还需要其他依赖项吗?

最佳答案

Ubuntu 镜像在软件包列表中没有任何内容,因此您需要 apt update然后 apt install git-all .
添加 -y如果您将它们放入 RUN 中的选项Dockerfile 中的命令。

关于git - Docker 无法在 Ubuntu 容器上安装 git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67740269/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com