Zhixian's Tech Blog

2022-04-17

How to pushing container image to Docker Hub using MiniKube

Filed under: computing, docker, minikube, Uncategorized — Tags: , , , , , — Zhixian @ 21:09:04 pm

Blog describing pushing a container image using MiniKube.

MiniKube actually has a copy of Docker executable in it.
We will be using that copy to login to Docker Hub and push our container image.

Assumptions

Steps

  1. SSH to MiniKube
  2. Re-tag our image
  3. Log in to Docker Hub
  4. Push container image to Docker Hub

SSH to MiniKube

To login to MiniKube, execute the following command:

minikube ssh

After the command finished executing, you should see an output like the below:

Re-tag our image

To push our local container image to Docker hub, we need to re-tag the container image from
<image-name>:<tag>
into the format of
<docker-hub-username>/<image-name>:<tag>

Before that, let’s take a look at the images that are available by running this command:

docker image ls

The container that we want to push to Docker Hub is “basic-mvc“.
My Docker Hub username is zhixian

So I want to re-tag my local image to zhixian/basic:mvc:1
To do so, execute the command:

docker tag basic-mvc:1 zhixian/basic-mvc:1

After I finished executing the command and re-examine the images, I would see that I have an image tagged as zhixian/basic-mvc:1
Note that the image ID is the same as basic-mvc:1

docker login

To push this image, we need to login to our Docker Hub account by running the following command in MiniKube SSH:

docker login

The command will prompt you for enter your Docker Hub username and password.
The following screenshot is what you should be seeing when you successfully log in.

Push container image to Docker Hub

To push the image to Docker Hub, run the command
docker push <docker-hub-username>/<image-name>:<tag>.
So in my case, the command would look like:

docker push zhixian/basic-mvc:1

Aside: Pushing the image may take a long time. Not sure if its because I’m using the free tier or its due to MiniKube. 🤔

After the command finished, you should be able to see it in your Docker Hub.

Reference

Repositories (https://docs.docker.com/docker-hub/repos/)

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.