apt-get update: Usage, Options & Common CI Errors
apt-get update downloads the latest package lists so apt knows what is installable.
apt-get update does not install anything - it refreshes the index of available packages. Skipping it is the most common reason a fresh Debian/Ubuntu image cannot find a package that clearly exists.
What it does
apt-get update resynchronizes the local package index from the sources listed in /etc/apt/sources.list and /etc/apt/sources.list.d/. It must run before apt-get install on a fresh image because base images ship with an empty or stale index.
Common usage
apt-get update
apt-get update && apt-get install -y curl
apt-get update -o Acquire::Retries=3 # retry flaky mirrors
DEBIAN_FRONTEND=noninteractive apt-get updateCommon errors in CI
The signature one bites hardest: "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 1234ABCD" means a repo's GPG key is missing - import it (gpg --dearmor into /etc/apt/keyrings and reference it with signed-by=) before updating. "Failed to fetch ... 404 Not Found" means a release was moved or the suite name is wrong (e.g. an EOL Ubuntu moved to old-releases.ubuntu.com). "Could not resolve host" is a network/proxy issue in the runner.
Options
| Flag | What it does |
|---|---|
| -y / --yes | Assume yes (used with install, not update) |
| -o KEY=VALUE | Set a config option (e.g. Acquire::Retries=3) |
| -q / -qq | Quiet output (good for logs) |
| --allow-releaseinfo-change | Accept a changed suite/codename |