Free tools Windows power users keep installed
One-click scans. No signup required.
The Docker build error E: Unable to locate package curl usually means that APT has no usable package index in the image, not that curl is unavailable from Debian or Ubuntu. Run apt-get update and apt-get install in the same Dockerfile RUN instruction, inspect the update output for network errors, and remove the downloaded lists after installation to avoid leaving unnecessary data in the image.
Antihost offers VPS plans with one-click Docker, NVMe storage and a 14-day free trial.
What the error actually means
Debian- and Ubuntu-based images use APT to resolve and install packages. APT does not search a live repository every time an install command runs. It consults package indexes stored locally in the image. Those indexes contain the package names, versions, repository locations and dependency metadata that APT needs before it can install anything.
As an Amazon Associate I earn from qualifying purchases.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
A fresh base image can have an empty or stale index. If the Dockerfile immediately runs apt-get install curl, APT checks its local lists, fails to find a matching entry and prints:
E: Unable to locate package curl
That message describes the state of the local metadata. It does not, by itself, prove that the curl package has been removed from the distribution or that the package name is invalid. The first corrective action is to download current indexes with apt-get update.
#1 Best Overall
The standard Dockerfile fix
For a Debian-based image such as debian:bookworm-slim, use one layer for both the update and the installation:
FROM debian:bookworm-slim
RUN apt-get update
&& apt-get install -y --no-install-recommends
ca-certificates
curl
&& rm -rf /var/lib/apt/lists/*
The command sequence has three deliberate parts:
apt-get updatedownloads the package indexes used by APT.apt-get install -y --no-install-recommends ca-certificates curlinstalls curl without waiting for an interactive confirmation. The--no-install-recommendsoption omits packages that are merely suggested rather than required.rm -rf /var/lib/apt/lists/*deletes the downloaded index files after installation, reducing data retained in the resulting image.
The backslashes are Dockerfile line continuations. The && operators make each command depend on the preceding command succeeding. If the update cannot complete, the install is not attempted against incomplete metadata, and the build stops at the step that needs attention.
Why apt-get update and apt-get install belong in one RUN
Docker builds each RUN instruction as a separate layer and can reuse those layers from its cache. Consider this pattern:
RUN apt-get update
RUN apt-get install -y curl
It looks equivalent, but it creates a cache hazard. Docker may reuse the earlier update layer even after the repository metadata in that layer has become old. The later install then runs with stale lists. A build can therefore appear to “run” the update while still failing to resolve a package.
Combining the commands ties the install to the exact update operation used to prepare it:
RUN apt-get update && apt-get install -y --no-install-recommends curl
Appending the cleanup to the same instruction keeps the indexes out of the final layer as well. Do not split update, install and cleanup into independent RUN instructions when writing a Dockerfile that should remain reliable as the base image and repository metadata change.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsApply the fix step by step
1. Confirm that the image uses APT
Look at the first instruction in the Dockerfile. The procedure in this article applies to Debian- and Ubuntu-based images, for example:
FROM debian:bookworm-slim
The base image determines the package manager, repository configuration and release in which a package name must exist. Do not copy an APT command into an image based on a different Linux distribution without checking that distribution’s package manager and package names.
2. Replace the install-only layer
Find a line like:
RUN apt-get install -y curl
Replace it with an update-and-install sequence. Include --no-install-recommends when you want only required dependencies, and add ca-certificates when the image needs the certificate bundle used by HTTPS connections:
RUN apt-get update
&& apt-get install -y --no-install-recommends
ca-certificates
curl
&& rm -rf /var/lib/apt/lists/*
Keeping the package names on separate continuation lines makes it easier to review or extend the list while preserving one logical layer.
3. Rebuild and read the complete log
Run your normal Docker build again and watch the output from the update command, not only the final install message. A successful-looking install line cannot compensate for an update that failed earlier. If the build system reused a previously cached result while you are diagnosing the Dockerfile, perform a cache-free diagnostic build so that the update instruction is executed again. Once the Dockerfile is correct, retain the combined command rather than relying on a cache-free build as the permanent solution.
4. Verify the result inside the image
After a successful build, start the image or add a temporary diagnostic step that invokes:
curl --version
A version response confirms that the executable was installed. Remove temporary diagnostic commands before publishing the final image if they are not needed at runtime.
If the combined command still fails
When the install continues to report that it cannot locate curl after the commands have been combined, the update step itself is the next place to look. The most useful information is usually earlier in the build output.
Look for repository or DNS failures
An update that cannot reach its mirror leaves APT with old or missing indexes. One example is an error such as:
Rank #4
Temporary failure resolving ...
That is a name-resolution or connectivity failure while contacting a repository host. Repeating apt-get install will not repair it, because the package metadata was never refreshed. Check the update output for the first warning or error, identify the mirror host it could not resolve, and correct the build environment’s network or DNS access before investigating the package name.
Do not suppress the update output while troubleshooting. A quiet or failed update can make the later “unable to locate” message look like the root cause even though it is only the consequence.
Check whether a cached layer is hiding the problem
Docker’s layer cache can preserve an earlier update result. If the base image, repository configuration or network conditions have changed, rebuild the update-and-install instruction rather than assuming a cached layer contains current lists. A cache-free build is useful for isolating this possibility; it does not replace the requirement to keep update and install together in the Dockerfile.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Confirm the package name for the selected release
Package names are not universal across every Linux release or every base image. The image’s FROM line selects a distribution and release, and that release determines which package names are available. Verify that the package is present for the specific Debian or Ubuntu release represented by the base image. If you change the base image to another release, repeat that check instead of assuming every package name remains identical.
Consider architecture only when the evidence points there
One Docker for Mac discussion described an Apple Silicon build in which pinning the image platform in the first line resolved an APT failure:
Best Value
FROM --platform=linux/amd64 debian:bookworm-slim
This is a report from a single case, not a general explanation for every “unable to locate package” error. Treat it as a targeted experiment when the failure occurs on Apple Silicon and the ordinary update-and-install sequence does not work. Keep the platform declaration only when it matches the image and deployment architecture you actually intend to use; otherwise, first resolve update, DNS, mirror and release issues.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common Dockerfile mistakes and their symptoms
| Dockerfile situation | What APT sees | Corrective action |
|---|---|---|
apt-get install runs without a preceding update |
The local package lists are empty or stale, so curl is not known locally. | Run apt-get update and install in the same RUN instruction. |
| Update and install are separate cached layers | Docker can reuse old metadata for the update layer. | Combine the commands with && so the install uses the update performed for that layer. |
| The update reports a mirror or DNS error | No current index was downloaded, even if the build reaches the install line. | Fix the network or name-resolution failure and rerun the update. |
| The base image release changed | The package database may use different package names or repository contents. | Confirm curl’s package name for the release selected by FROM. |
| Indexes are left in the final layer | The image retains APT list files that are no longer needed at runtime. | Remove them with rm -rf /var/lib/apt/lists/* in the same RUN. |
Understanding the cleanup and dependency options
Why remove /var/lib/apt/lists/*?
The update command downloads repository index files so APT can resolve packages. Once curl and its required dependencies are installed, those lists are not needed to execute curl. Removing them in the same layer prevents the final image from carrying the temporary index data. The cleanup does not uninstall curl; it removes only the downloaded list files.
What --no-install-recommends changes
APT can distinguish between packages required for an installation and packages marked as recommendations. The --no-install-recommends flag tells APT to omit the latter. That generally produces a smaller, more focused image, but it also means software that expects a recommended package must declare or install that dependency explicitly. The flag does not replace -y; -y answers confirmation prompts, while --no-install-recommends changes which optional dependencies are selected.
A practical diagnostic checklist
Use this order so that each check addresses a different failure mode:
- Read the
FROMline and confirm that the image is Debian- or Ubuntu-based. - Ensure the Dockerfile runs
apt-get updatebeforeapt-get install. - Ensure update, install and list cleanup are joined in one
RUNinstruction with&&. - Rebuild the relevant layer and inspect every line printed by the update command.
- If you see “Temporary failure resolving” or another mirror error, fix connectivity or DNS before changing package names.
- Confirm that curl is named and available for the release selected by the base image.
- If the failure is limited to an Apple Silicon Docker for Mac setup, test the reported
linux/amd64platform declaration and verify that the chosen architecture is appropriate for deployment. - After a successful install, remove
/var/lib/apt/lists/*and verify curl withcurl --version.
What not to change first
Do not begin by repeatedly adding install flags or by assuming that curl has disappeared from Debian or Ubuntu. The error is most often caused by missing local metadata. Do not split the update and install into separate layers to make the Dockerfile look shorter, because that makes cache reuse less reliable. Do not hide update output while diagnosing the build, since the decisive failure may occur before APT reaches the install command.
Also avoid applying this exact command sequence to an unrelated distribution without checking its package manager. The procedure here is specifically for APT-based Debian and Ubuntu images; a different base image may require different commands and package naming.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11A reliable final pattern
For a Debian or Ubuntu Dockerfile that needs curl, the durable pattern is straightforward:
FROM debian:bookworm-slim
RUN apt-get update
&& apt-get install -y --no-install-recommends
ca-certificates
curl
&& rm -rf /var/lib/apt/lists/*
This ordering gives APT current metadata, makes installation fail when the update fails, avoids stale cached update layers and removes temporary index files after the package is installed. If it still does not build, the update output identifies whether the remaining issue is repository access, name resolution, architecture selection or a package-name mismatch for the chosen release.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




