Use local docker image without registry setup in k8s


I've set up single node kubernetes according to official tutorial.

In addition to official documentation I've set-up single node cluster:

kubectl taint nodes --all node-role.kubernetes.io/master-

Disabled eviction limit:

cat << EOF >> /var/lib/kubelet/config.yaml evictionHard: imagefs.available: 1% memory.available: 100Mi nodefs.available: 1% nodefs.inodesFree: 1% EOF systemctl daemon-reload systemctl restart kubelet

And set systemd driver for Docker:

cat << EOF > /etc/docker/daemon.json { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "storage-driver": "overlay2" } EOF systemctl daemon-reload systemctl restart docker

I've tried following:

docker build -t localhost:5000/my-image . kubectl run -it --rm --restart=Always --image=localhost:5000/my-image my-image

But in pod logs I see ImagePullBackOff. If I setup local repository and I do docker push localhost:5000/my-image after I build image, then everything is working.

Is it is possible to use local images (which are already available after issuing docker images) without needing to setting up local repository, pushing to this repository and then pulling from it?


You simply need to set the imagePullPolicy in your Pod template in the container specification to Never. Otherwise the kubelet will try to pull the image. The example Pod definition may look like this:

apiVersion: v1 kind: Pod metadata: name: test spec: containers: - name: uses-local-image image: local-image-name imagePullPolicy: Never

More on that you can find here.


By default, the kubelet will try to pull each image from the specified registry. However, if the imagePullPolicy property of the container is set to IfNotPresent or Never, then a local image is used (preferentially or exclusively, respectively).

If you want to rely on pre-pulled images as a substitute for registry authentication, you must ensure all nodes in the cluster have the same pre-pulled images.

This can be used to preload certain images for speed or as an alternative to authenticating to a private registry.

All pods will have read access to any pre-pulled images.


mario's answer is correct. Would be complete with the command though. So, you want to create your deployment as follows:

kubectl run -it --rm --restart Always DEPLOYMENT_NAME --image my-image --image-pull-policy IfNotPresent COMMAND

Note: if you'd have more then one node, you would need to ensure on all of them you have an image with that name, as a repo doesn't exist, and it will fail.



  • Cannot use mutating member on immutable value of type
  • Use local docker image without registry setup in k8s
  • Running two threads which are dependent on each other in a loop
  • Slow Postgres 9.3 queries
  • Explanation regarding Spring security URL based security [duplicate]
  • sql messages table query
  • Does Selenium WebDriver for Java require some sort of IDE like Eclipse in order to run?
  • ListView Grouping does not update when bound property is changed
  • How to generate a rails link with an AR validation message
  • Custom keyboard appears with ~5seconds delay
  • create version.txt file in project dir via build.gradle task(gradle 5.0)
  • Regex to match full lines of text excluding crlf
  • $_POST is not working in ajax form submit?
  • Bash: expand parameters from variable. How?
  • MySQL and average of multiple columns + indivudual condition for each of the columns
  • spring security client_credentials grant_type - support for refresh token
  • Kotlin Higher Order Function Composition
  • Amazon API generating a request signature in C# .NET
  • spinlock initialization function
  • Binding producing 2 security tags , soap xml with 2 X509's+ usernmaetoken with nonce
  • How deleteLater() actually works in qt?
  • How to read config files with section in bash shell
  • Http Requests not getting routed to Https NodeJs
  • How to add tag during runtime in C#
  • Preloading webView doesn't work - trying to reduce loading time
  • Eric5: The OK button of 'new project' dialog is disable
  • Jekyll - How do I create pages in the root directory?
  • How to reduce a DAG by replacing each longest non-branching path by an edge connecting the start and
  • Jenkins sending notifications to the wrong commit id
  • How can I filter an array of dictionaries in 'updateSearchResultsForSearchController' to s
  • readmore button or show/hide for php
  • Annotate objects in a queryset with next and previous object ids
  • Grails - How to implement a foreign key relationship not using an id column?