“Failed to inspect image XXX: Id or size of image

2019-08-05 20:03发布

问题:

I'm attempting to deploy a Docker container to a minikube instance running locally, and getting this error when it attempts to pull(?) the image. The image exists in a self-hosted Docker registry. The image I'm testing with is built with the following Dockerfile:

FROM alpine:latest
ENTRYPOINT ["echo"]

I'm using the fabric8io kubernetes-client library to create a deployment like so:

// 'kube' is an instance of io.fabric8.kubernetes.client.KubernetesClient
final Deployment deployment = kube.extensions().deployments()
        .createOrReplaceWithNew()
        .withNewMetadata()
            .withName(name)
            .withNamespace("staging")
        .endMetadata()
        .withNewSpec()
            .withReplicas(1)
            .withNewTemplate()
                .withNewMetadata()
                    .addToLabels("app", name)
                .endMetadata()
                .withNewSpec()
                    .addNewImagePullSecret()
                        // "regsecret" is the kubectl-created docker secret
                        .withName("regsecret")
                    .endImagePullSecret()
                    .addNewContainer()
                        .withName(name)
                        .withImage(imageName + ":latest")
                    .endContainer()
                .endSpec()
            .endTemplate()
        .endSpec()
        .done();

This is all running on Arch Linux, kernel Linux 4.10.9-1-ARCH x86_64 GNU/Linux. Using minikube 0.18.0-1 and kubectl-bin 1.6.1-1 from the AUR, docker 1:17.04.0-1 from the community repositories, and the docker registry container at latest (2.6.1 as of writing this). fabric8io kubernetes-client is at version 2.2.13.

I have checked:

  • that the self-hosted registry is running over HTTPS correctly
  • that the image can even be pulled. docker pull and docker run on both the host and inside the minikube VM work exactly as expected
  • that the image runs. See above
  • that there aren't any name conflicts / etc. in minikube. I delete the deployments, replica sets, and pods between attempts, and I recreate the namespace, just to be safe. However, I've found that it doesn't make a difference which I do, as my code cleans up existing pods/replica sets/deployments as needed
  • that DNS is not an issue, as far as I can tell

I have not:

  • run kubernetes locally (as opposed to minikube), as the AUR package for kubernetes takes an unbelievably long time to build on my machine
  • read through the kubernetes source code, as I don't know golang

When checking minikube dashboard, the sections for Deployments, Replica Sets, and Pods all have the same error:

Failed to inspect image "registry_domain/XXX/YYY:latest": Id or size of image "registry_domain/XXX/YYY:latest" is not set
Error syncing pod, skipping: failed to "StartContainer" for "YYY" with ImageInspectError: "Failed to inspect image \"registry_domain/XXX/YYY:latest\": Id or size of image \"registry_domain/XXX/YYY:latest\" is not set"

and the pod logs are permanently stuck at

container "YYY" in pod "YYY" is waiting to start: ImageInspectError

Looking up the error message provided leads me to https://github.com/kubernetes/minikube/issues/947, but this is not the same issue, as kube-dns is working as expected. This is the only relevant search result, as the other results that come up are

  • Slack chatroom archives that don't even contain the relevant error message
  • The kubernetes source, which isn't helpful to me
  • kubernetes/minikube #947, as above

I'm honestly not sure where to go from here. Any advice would be appreciated.

回答1:

Kubernetes 1.6 may not compatible with latest Docker version(17.xx.xx), could you lower down your Docker version and retry this.

The recommend version of Docker in Kubernetes(v1.6) is 1.12, if you not sure how to find that version. Use this in ubuntu or debain:

apt-get update && apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y docker.io

For centos, ref

remove you current Docker install before trying this



回答2:

Before removing anything, you can try minikube delete (if nothing important in there, or stuff backed up) and minikube start so that you delete you previous cluster alltogether, and try yo pull your image again. It did it for me.