Sunday, 30 August 2020

How to Push the Images to Docker Hub

1.Packaging

Package your spring applications using the following command.

mvn package

This Command will do the package as specified on the pom.xml.

2.Containerization.

Tag the docker Image.

Tag the Image with the Name in the local.

docker build -t searchio/gs-search-boot-docker .

If you have any dependencies then you can copy by the following way.

mkdir -p target/dependency

cd target/dependency; jar -xf ../*.jar

Once if you do this, it will copy all the dependency jars to the target/dependency.


3.Running the Docker Image.

docker run -p 8080:8080 searchio/gs-search-boot-docker

To run the docker Image use the above command.


4.Build the Image.

mvn spring-boot:build-image -D spring-boot.build-image.imageName=searchio/gs-search-boot-docker

After building follow the Below steps to Push the Image to the Docker Hub.

1. Docker Login.

docker login

UserName:

Password:

provide the username and password here. Once the login is success.


2. Create a repo 

in the docker hub eg: my-first-rep


3. Tag our Image build.

docker tag searchio/gs-search-boot-docker syedghouse14/my-first-repo:push1


here searchio/gs-search-boot-docker is the local tag and syedghouse14/my-first-repo:push1 is the repo created in the docker hub.

Once you follow the above steps then the next step is to push it to the repo and to the docker hub .

5. Push the Image to Docker Hub.

docker push syedghouse14/my-first-repo:push1

No comments:
Write comments