Local Docker Images on Kubernetes – Docker for Windows

Failed to pull image “testapp:latest”: rpc error: code = Unknown desc = Error response from daemon: pull access denied for testapp, repository does not exist or may require ‘docker login’

Why??? It is there…

I just installed Docker for Windows + Kubernetes on my PC because I wanted to test some changes I made to the Kubernetes C# client, so I quickly created an easy .Net Core Console App and made an image with:

FROM microsoft/dotnet:2.1-sdk-alpine AS build 
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

FROM microsoft/dotnet:2.1-runtime-alpine AS runtime
WORKDIR /app
COPY --from=build /app/out ./
ENTRYPOINT ["dotnet", "TestApp.dll"]

Then I built it with:

docker build -t testapp .

Checked the images in docker:

Good, it is in my local image store. So I could run it now in Kubernetes with the Kube file I created:

apiVersion: batch/v1
kind: Job
metadata:
  name: testapp-job
  labels:
    app: testapp
spec:
 template:
   spec:
      containers:
      - name: testapp-job
        image: testapp:v1
      restartPolicy: Never

So I ran:

kubectl create -f .\Kube.yml

And checked the Kubernetes Dashboard:

Well it has nothing to do with the login or the repository. It’s more about the tag, it makes Kubernetes not look into your local store for some reason.

How do you fix this:

Just apply a different tag and use that. As simple as that.

So I quickly changed “latest” to “v1”.

docker build -t testapp:v1 .

The image with the v1 tag is now there.

Changed the kube file to use v1 instead of latest.

image: testapp:v1

Ran kubectl again.

kubectl create -f .\Kube.yml

And now the job runs fine:

That was easy but it is also annoying and you might not think about it, if you just want to test something quickly.

I know I could have used:

kubectl run testapp --image=testapp:v1

But I like the kube files.

Leave a Reply

Your email address will not be published.