The post Using Jenkins to Build and Deploy Docker images appeared first on Little Big Extra.
]]>Jenkins is one of the most popular continuous integration tools and is widely used. It can be used to create pipelines, run jobs and do automated deployments.
There are many plugins available which can be added to Jenkins and makes it really powerful.
Recently I wanted to do an automated deployment of Docker Images to docker server and tried using docker-plugin but after spending some time it looked to me that if it asking for too much of information and for each operation you need to provide arguments, I would prefer a solution which is more dynamic and picks things automatically with user providing the bare essentials parameters arguments.
This is how it looks like
In a nutshell, all I wanted was
Once all 3 steps have been tested and completed all is left to be done in Jenkins is to Invoke the clean install goal as shown below.
If you want to push the docker image to some repository after building, testing and deploying.Please follow this link
The post Using Jenkins to Build and Deploy Docker images appeared first on Little Big Extra.
]]>The post How To Push Docker Images To Docker Hub Repository Using Docker Maven plugin appeared first on Little Big Extra.
]]>
If you want to push a docker image to Docker Hub repository, it can be achieved using docker maven plugin from fabric8.io. This plugin lets you build images, start and stop containers and push it to Docker repositories
&nsbp;
<plugin> <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.20.0</version>....
<name>springboot-mongo-dockerimage:${project.version}</name> <alias>springboot-mongo-dockerimage</alias> <build> <dockerFileDir>${project.basedir}</dockerFileDir> </build>
<registry>registry.hub.docker.com/YOUR_DOCKER_HUB_USERNAME</registry>
<authConfig> <username>ENTER YOUR DOCKER HUB USERNAME LIKE abhishek</username> <password>ENTER YOUR DOCKER HUB PASSWORD</password> </authConfig>
<execution> <id>push</id> <phase>post-integration-test</phase> <goals> <goal>push</goal> </goals> </execution>
Here is the complete build section from the plugin, hope this help.
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.20.0</version> <configuration> <registry>registry.hub.docker.com/YOUR_DOCKER_HUB_USERNAME</registry> <images> <image> <name>springboot-mongo-dockerhub:${project.version}</name> <alias>springboot-mongo-dockerhub</alias> <build> <dockerFileDir>${project.basedir}</dockerFileDir> </build> <run> <namingStrategy>alias</namingStrategy> <dependsOn> <container>mongo</container> </dependsOn> <links> <link>mongo</link> </links> <ports> <port>9876:8080</port> </ports> <log> <prefix>TC</prefix> <date>default</date> <color>cyan</color> </log> </run> </image> </images> <authConfig> <username>ENTER YOUR DOCKER HUB USERNAME LIKE abhishek</username> <password>ENTER YOUR DOCKER HUB PASSWORD</password> </authConfig> </configuration> <executions> <execution> <id>start</id> <phase>pre-integration-test</phase> <goals> <goal>stop</goal> <goal>build</goal> <goal>start</goal> </goals> </execution> <execution> <id>push</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> <goal>push</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
If you get an error : io.fabric8:docker-maven-plugin:0.20.0:build failed: A tar file cannot include itself
The post How To Push Docker Images To Docker Hub Repository Using Docker Maven plugin appeared first on Little Big Extra.
]]>The post Build and deploy Docker Image with Docker Maven plugin appeared first on Little Big Extra.
]]>
The maven plugin for docker fabric8io/docker-maven-plugin helps us in building docker images and running containers. In case you are thinking about the difference between an image and container then please note that a running image is called container.
In this tutorial, we are going to
<plugin> <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.20.0</version>....
<name>springboot-mongo-dockerimage:${project.version}</name> <alias>springboot-mongo-dockerimage</alias> <build> <dockerFileDir>${project.basedir}</dockerFileDir> </build>
<dependsOn> <container>mongo</container> </dependsOn> <links> <link>mongo</link> </links>
<ports> <port>9876:8080</port> </ports>
<executions> <execution> <id>start</id> <phase>pre-integration-test</phase> <goals> <goal>stop</goal> <goal>build</goal> <goal>start</goal> </goals> </execution>
Here is the complete build section from the plugin, hope this help.
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.20.0</version> <configuration> <!--<dockerHost>tcp://REMOTE_IP:2375</dockerHost>--> <images> <image> <name>springboot-mongo-dockerimage:${project.version}</name> <alias>springboot-mongo-dockerimage</alias> <build> <dockerFileDir>${project.basedir}</dockerFileDir> </build> <run> <namingStrategy>alias</namingStrategy> <dependsOn> <container>mongo</container> </dependsOn> <links> <link>mongo</link> </links> <ports> <port>9876:8080</port> </ports> <log> <prefix>TC</prefix> <date>default</date> <color>cyan</color> </log> </run> </image> </images> </configuration> <executions> <execution> <id>start</id> <phase>pre-integration-test</phase> <goals> <goal>stop</goal> <goal>build</goal> <goal>start</goal> </goals> </execution> <!-- Uncommment this execution phase if you wan to remove container after testing -> <!--<execution> <id>clean image</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> --> </executions> </plugin> </plugins> </build>
If you get an error : io.fabric8:docker-maven-plugin:0.20.0:build failed: A tar file cannot include itself
The post Build and deploy Docker Image with Docker Maven plugin appeared first on Little Big Extra.
]]>