Push Docker image in Tar ball to a OpenShift Docker - docker

I have a jenkins in a standalone Windows 7 server. We have a request to add a build job to build a project, which produce a Docker image in Tar ball format, and push the image into a remote Docker Registry, which resides in OpenShift.
Trying to find a jenkins plugin that can do this. Found that Docker Common plugin have some command but as i understood it can push the image only from a docker registry to another.
Any guide where i can push the tar ball to a remote registry through a standalone jenkins? Thank you.

may be this can be helpful, you can run docker on local windows server, and then load the image tar to local docker then push it to remote repo. Steps are given in this link.
https://docs.openshift.com/container-platform/3.11/install/disconnected_install.html#disconnected-populate-registry

Related

How to pull new docker images and restart docker containers after building docker images on gitlab?

There is an asp.net core api project, with sources in gitlab.
Created gitlab ci/cd pipeline to build docker image and put the image into gitlab docker registry
(thanks to https://medium.com/faun/building-a-docker-image-with-gitlab-ci-and-net-core-8f59681a86c4).
How to update docker containers on my production system after putting the image to gitlab docker registry?
*by update I mean:
docker-compose down && docker pull && docker-compose up
Best way to do this is to use Image puller, lot of open sources are available, or you can write your own on the Shell. There is one here. We use swarm, and we use this hook concept to be triggered from our CI-CD pipeline. Once our build stage is done, we http the hook url, and the docker pulls the updated image. One disadvantage with this is you need a daemon to watch your hook task, that it doesnt crash or go down. So my suggestion is to run this hook task as a docker container with restart-policy as RestartAlways

Build a docker image on Gitlab CI/CD with alpine

I would like to build docker-image on Gitlab CI/CD with alpine. This docker has to download a website (only index.html) as a file with a date every 1 hour.
All dates/ files should be saved in the docker volume.
How to start with this? I am new in docker.
First you need to run a docker container using any image you want (alpine in your case).
Then set everything in it that you want to run (like download website)
Then create a docker image and host it on gitlab docker registry
Then you simply have to code .gitlab-ci.yaml file. After pushing that to your repository
Then you need to schedule your pipeline as mentioned here
https://docs.gitlab.com/ee/user/project/pipelines/schedules.html

Docker build and push git code inside Azure devops

I have a docker file which copies some code from git. When I put this docker file as part of Azure devops pipeline I am unable to get the code inside container. is git clone the only option or is there any way out of this?
The container is not having internet access to connect to the git repository. You can prebuild your image from local system and use the image from docker images registry.

How to pull docker image from github and build image in ec2?

My actual requirement is pull docker image from GitHub and build a docker image in ec2 instance and push that image to ecr. So, am just trying to clear my first step by asking help to pull image from git, very new to all this.
Let's walk through each step you're asking about in your requirements:
Pull from GitHub - You won't pull a docker image from here, however you may pull a Dockerfile from here, which would be used to build an image. The command to do this would be just like cloning any other repository: git clone <repository url>
Build the image on ec2 - First you will need to have docker installed on the ec2 instance. Assuming you're running Ubuntu on your ec2 instance, follow the good instructions on Docker's page (https://docs.docker.com/install/linux/docker-ce/ubuntu/) miror. Once docker is installed, navigate to the directory that has your Dockerfile in it (cloned from git) and type docker build . --tag mytag
Push the image to ecr - To do this, you need to have the amazon CLI installed on your box, and you need an ACCESS_KEY_ID and SECRET_ACCESS_KEY from AWS IAM. Once you have these, configure your connection by storing them as environment variables, or by typing aws configure and entering them. Once your credentials are configured, log into ECR by typing aws ecr get-login --no-include-email, and then copy/pasting the command it gives you. (you can also put ` around it to skip the copying step). This will allow you to push to ecr using docker push.
To clarify some of the points:
Github: It is a web-based hosting service for version control using git. So you can not pull docker image from Github.
To build a Docker image, you need Dockerfile. So you can fork the GitHub project which has this Dockerfile.
Then to build it on ec2, you can check out the project containing Dockerfile on ec2 server and build it using:
https://docs.docker.com/engine/reference/commandline/build/
and then you can push it to any registry using:
https://docs.docker.com/engine/reference/commandline/push/

Jenkins docker plugin + commit docker slave, how to push it to a external registry. Image saved on docker host configured in cloud template

I am able to start up a jenkins docker slave. I execute some shell command on the slave, after the build completes the image gets saved and tagged with build id of the job.
However, the image is getting saved into the docker host machine (i.e) the hostname of the machine given on the cloud template (Docker URL).
I want the image to be pushed or saved on a different docker registry.
jenkins machine
docker host (hosting jenkins slaves)
docker registry
I am using machine 1 to pull image from 3. Making changes to the image, on successful build push the image to 3 not to 2.
Take a look at running a Docker Distribution private registry server so you can pull and push to it.
Once you get that up and running, you can:
docker login https://<URL_OF_PRIVATE_REGISTRY>
docker pull <URL_OF_PRIVATE_REGISTRY>/<IMAGE_NAME>:<IMAGE_TAG>
docker tag <LOCAL_IMAGE_NAME> <URL_OF_PRIVATE_REGISTRY>/<IMAGE_NAME>:<IMAGE_TAG>
docker push <URL_OF_PRIVATE_REGISTRY>/<IMAGE_NAME>:<IMAGE_TAG>

Resources