Joseph Hwang
Joseph Hwang

Reputation: 1421

how to pull locally built docker image on windows 10?

My os is windows 10 pro and I develop with spring boot. First I build docker image with below Dockerfile.

FROM openjdk:11-jdk
ADD target/Spring-Blog-Jpa-0.0.1-SNAPSHOT.jar blog-app.jar
EXPOSE 8080
ENTRYPOINT ["java","-Dfile.encoding=UTF8","-jar","blog-app.jar"]

The docker image is built successfully with the docker command.

> docker image build -t blog-app:latest .

And I pull mysql:latest image from docker repository. And mysql pulling is also successful.

> docker image pull mysql:latest .

I try to generate kubernetes pod with those docker images. In case of mysql:latest image, mysql pod is generated without errors. But when generating the blog-app pod, the blog-app:latest image can not be pulled and error message is thrown. Below is the configuration yaml file.

apiVersion: apps/v1
kind: Pod
metadata:
  name: blog-system
spec:
  containers:
  - name: blog-app
    image: blog-app:latest
    args: ["-t", "-i"]

I have no idea why the locally built image can not be pulled when generating pod. Is there any process to push local docker repository? How can the locally built docker images can be pulled on Kuberetes?

Upvotes: 0

Views: 3675

Answers (1)

Arghya Sadhu
Arghya Sadhu

Reputation: 44569

You can reuse the Docker daemon from Minikube. Here are the commands on Powershell.

PS C:\minikube> minikube docker-env

PS C:\minikube> minikube docker-env | Invoke-Expression

docker image build -t blog-app:latest

Set the image in the pod spec like the build tag

Set the imagePullPolicy to Never, otherwise Kubernetes will try to download the image.


apiVersion: apps/v1
kind: Pod
metadata:
  name: blog-system
spec:
  containers:
  - name: blog-app
    image: blog-app:latest
    imagePullPolicy: Never
    args: ["-t", "-i"]

Also check this guide

Upvotes: 2

Related Questions