Docker not able to install git on Ubuntu container

  apt, docker, git, sudo, ubuntu

I have a Docker image that uses ubuntu:21.04. When I SSH onto it I try to install git using the official Git Ubuntu installation instructions but I get an error:

[email protected]:/home/ubuntu# sudo apt install git-all
bash: sudo: command not found

I’m surprised to see sudo doesn’t exist! So I try it without sudo:

[email protected]:/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

So I ask: what command(s) can I run to install git on a Dockerized Ubuntu 21.04 container?

Update

When I add the following to my Dockerfile:

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

and then rebuild the image, I get:

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.

Are there any other dependencies I need?

Source: Docker Questions

LEAVE A COMMENT