我有一个使用ubuntu:21.04
的Docker镜像。当我SSH进去后,我尝试按照官方Git Ubuntu安装说明安装git,但是出现了错误:
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
所以我想问:在Docker化的Ubuntu 21.04容器上,我可以运行什么命令来安装git
?
更新
这是我的完整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
我还需要哪些依赖项?
docker run -it ubuntu:21.04 bash
命令测试了这些命令,然后直接进入了apt
命令。 - AdamF