How to build docker image using jenkins and Google Cloud Compute engine VM?
How to use Jenkins with ssh and docker to
Jenkins is used for creating docker images and then using Jenkins we can push this to the google cloud platform based VM. Here We have steps for how to build a docker image using Jenkins and build it to the google cloud compute engine VM.
If you are new to the jenkins then please visit the site Jenkins.
build on Google Cloud VM
For deploying the docker images on the google cloud platform VM, you need to create a docker image first using Jenkins(This is one of the ways you can do it.)
For using Google Cloud Engine – Compute Engine for deploying the Docker image one needs to do the below kind of setup on Jenkins.
1. Install Publish Over SSH Plugin in Jenkins
For installing this plugin follow the below steps,
how to install Jenkins plugins?
2. Go to Jenkins Configure Manager using Jenkins–> Manage Jenkins –> Configure System
You can go to the configuration directly using this link also http://<YOUR JENKINS URL>/configure
3. After installing Publish Over SSH, We can see the section called – Publish over SSH on the configuration screen,
Add SSH Server information like passphrase, server address, the private key for ssh, username, etc.
4. Now you can use the above SSH Server directly in any of the Jenkins batches in Build Triggers.
5. Need to Select the SSH server configured and provide the SSH command which do you want to run on Google Cloud VM.
i.e To run docker image on the VM using ssh then I need to run below command
docker run -p 1234:9000 -d <Image ID or Image path>
Exec command shown in Fig 1 will be run on the SSH terminal connected using the SIM INSTANCE profile.