An example is as follows:
As you can see from the output, we can see the “unable to find the image alpine:latest locally”.
Causes of the “Unable to Find the Image Locally” Message
Image Not Pulled
This message’s first and most common cause is if the image is not pulled. To use an image to create a container, the target image must be pulled from the Docker hub. Although Docker is configured to automatically pull the image from the hub if it is unable to find it locally, you can manually download it using the “pull” command:
For example:
This should pull the latest version of the Docker Alpine image.
Incorrect Name or Tag
The second cause of the “unable to find the image locally” error occurs if the specified name, image, and tag are incorrect. Including a typo in the name/tag of an image can lead to this error.
An example is as follows:
As you can see from the previous command, there is a typo in the image name. Running the previous command returns an error as follows:
Unable to find image ‘ubuntuu:latest’ locally
docker: Error response from daemon: pull access denied for ubuntuu, repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied.
Unbuilt Image
This error may occur in other cases if the target image is not built locally using the Docker “build” command. This is especially common if you are using a custom image.
To resolve this error, you can navigate to the directory that contains the Dockerfile and execute the “build” command to create the image:
This should build and output the image with the specified command. You can then reference the name in your Docker “run” command.
Docker Daemon Not Running
You may also encounter this error if the Docker daemon is not running. You can use the “systemctl” command to check if the service is running as follows:
Output:
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Fri 2023-09-08 05:00:42 UTC; 13s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Process: 868 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=0/SUCCESS)
Main PID: 868 (code=exited, status=0/SUCCESS)
CPU: 1.179s
In this case, we can see that the Docker daemon is stopped. To fix this error, we can use the command as follows:
Once started, you can re-run the command to pull the image and build the container.
Caching Issues
Lastly, you can encounter the “unable to find the image locally” message if Docker is having image caching issues. You can clean up the cache and re-run the command to fix this.
Conclusion
In this short tutorial, we explored the potential causes of the “unable to find the image locally” in Docker when attempting to pull an image or building a container.