Create Docker Image with Tag from .tar file and push in Private Docker Registery

Create Docker Image from .tar file

$ docker load --input my-dockerized-app-0.0.1.tar

Create a tag.

Before tag creating, i will learn my source image/newly created docker image ID for the tag creating command..

 $ docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

we can find that via “docker image ls”, but put the grep command, because i want only the same name having images seen, what I as grep argument given.

$ docker image ls | grep my-docker
my-dockerized-app                        0.0.1       c0f32faf4320   1 minute ago      

And now i can create a new tag for local or for private docker registry

Option 1. Tag for Only Local Using

$ docker tag c0f32faf4320 my-dockerized-app:0.0.1

Option 2. Tag for Local and over Local/Open Registry

$ docker tag c0f32faf4320 docker.d8devs.com/apps/my-dockerized-app:0.0.1
$ docker push docker.d8devs.com/apps/my-dockerized-app:0.0.1

Example Usage:

in docker-compose.yml

version: '3'
services:
    frontend:
        image: my-dockerized-app:0.0.1
......
.....
....

for Kubernetes deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-deployment
  labels:
    app: app-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app-test
  template:
    metadata:
      labels:
        app: app-test
    spec:
      containers:
      - name: frontend
        image: my-dockerized-app:0.0.1 // or docker.d8devs.com/apps/my-dockerized-app:0.0.1 (dont forget use the imagePullSecrets for privat Registry)

Views: 1597