Docker : Change open Jdk to oracle Jdk in Jenkins image - jenkins

I am very new to docker and I am trying to run a Jenkins image. I pulled the image from the repository and now am able to run it using the command
docker run -p 8080:8080 jenkinsci/jenkins
By default it uses openjdk version 1.8. I would like to use oracle Jdk instead of openjdk. How could I change this? Thanks in advance.

If you really want to use this image and change the jdk, you will have to build your own image from this one, install oraclejdk, setup Jenkins to use this jdk (like environment variables etc), but it is not a clean way, imho.
The best practice would be to build your own image from a oraclejdk Docker image and setup Jenkins on it.
You should look at other Dockerfiles to do this.

Oracle provides a bunch of docker images on github : https://github.com/oracle/docker-images
You should check your other requirements as well (OS, etc.)

Related

Creating Dockerfile quickly

I wanted a docker image with adoptopenjdk in alpine; installed with:
maven 3.6.3
kubectl latest
helm latest
git
maybe openshift
Is there a quick way to select a base image and then the aforementioned tools and get a Dockerfile, which I can further edit perhaps? It seems like something like that would be great to have and I expected it to be available. I went to Dockerhub and searching the tags, I can get maybe just the adoptopenjdk or maven or kubectl but not all-in-one bundle of my choosing. If there doesn't exist a thing like that what is the best way to go about it?
I would prefer pulling some separately, there’s none much differences thou.

How to start docker containers using shell commands in Jenkins

I'm trying to start two containers (each with different image) using Jenkins shell commands. I tried installing docker extension in Jenkins and/or setting docker in global configuration tools. I am also doing all this in a pipeline. After executing docker run... I'm getting Docker: not found error in Jenkins console output.
I am also having a hard time finding a guide on the internet that describes exactly what I wish to accomplish. If it is of any importance, I'm trying to start a Selenium Grid and a Selenium Chrome Node and then using maven (that is configured and works correctly) send a test suite on that node.
If u have any experience with something similiar to what I wish to accomplish, please share your thoughts as what the best approach is to this situation.
Cheers.
That's because docker images that you probably create within your pipeline cannot also run (become containers) within the pipeline environment, because that environment isn't designed to also host applications.
You need to find a hosting provider for your docker images (e.g. Azure or GCP). Once you set up the hosting part, you need to add a step to your pipeline to upload/push the image to that provider's docker registry or to the free public Docker Hub. Then, finally, add a step to your pipeline to send a command to your hosting, to download the image from whichever docker registry you chose, and to launch the image into a container (this last part of download and launch is covered by docker run). Only at that point you have a running app.
Good luck.
Somewhat relevant (maybe it'll help you understand how some of those things work):
Command docker build is comparable to the proces of producing an installer package such as MSI.
Docker image is comparable to an installation package (e.g. MSI).
Command docker run is comparable to running an installer package with the goal of installing an app. So, using same analogy, running an MSI installs an app.
Container is comparable to installed application. Just like an app, docker container can run or be in stopped state. This depends on the environment, which I referred to as "hosting" above.
Just like you can build an MSI package on one machine and run it on other machines, you build docker images on one machine (pipeline host, in your case), but you need to host them in environments that support that.

Jenkins + Artifactory in Red Hat

Good morning, I have a server with Red Hat Enterprise 7.6 (it can only be this one) installed and I have to install jenkins + jfrog artifactory.
The easiest way to do this would be with docker or installing them on the machine? The docker I already installed them but I do not know which is the most correct way to use them.
The docker seems to me better in the matter of I need to have other tools in that server and everything in container. In the future this machine will also have gitlab.
Thank you for your help
Docker Compose will be your best option and is the recommended option from JFrog's point of view for the scenario you're describing. We've added a bunch of examples of docker-compose scripts to our GitHub repos that should give you a great start.
You can user docker-compose tool.
Combine all required services in one yaml file.

Where is the Docker source code located (github repo)?

I need to install docker on Angstrom linux, In order to do that I would like to download the source code of docker, and make the files myself.
But I cannot find the source code?
docker.github.io is apparently just the documentation.
Thanks!
You need to build Moby, to make it simple, see Moby as the new name for Docker.
To do so, simply clone the git repository, checkout the tag you want and run a make command
git clone https://github.com/moby/moby.git
git checkout tags/VERSION
make
You will need to have Docker installed on your dev machine to build it.
Docker Desktop includes Docker Engine, Docker CLI client, Docker Compose, Docker Content Trust, Kubernetes, and Credential Helper.
As mentioned in https://github.com/docker/docker-ce/blob/master/README.md
The source code for Docker Engine is on:
https://github.com/moby/moby
The source code for docker CLI is on:
https://github.com/docker/cli
The source code of docker compose is on:
https://github.com/docker/compose
But to Bring these tools to a usable bundle, you need Docker Desktop.
The source code of Docker Desktop is on:
https://download.docker.com/
CAUTION: As you can see, the source code of Docker Desktop that they are providing is not under any version control system, thus hard to audit. So please be careful when putting this code in production.

What is the right way to add Maven and Ant to a Jenkins Docker container?

I downloaded the jenkins/jenkins:lts image from docker hub which I got up and running on Ubuntu 16.04. The image doesn't seem to include Ant or Maven, and may also want to do builds against different versions of the jdk. I am wondering what is the right way to adress this - can I just run bash on the container and run apt-get or yum as the case may be to install extra stuff needed for my builds, or is there a better way?
Jenkins can automatically install Maven and Ant.
First, install the Ant Plugin by going to Manage jenkins > Manage Plugin > Available and install the Ant Plugin.
Next go to Manage jenkins > Global tool configuration then add Maven and Ant.
Once a build requires Maven or Ant, they will be downloaded and installed.
Installing your tools directly in the running container is probably a bad idea as changes won't persist. Instead, I see the following options:
Let jenkins manage your tools like proposed by yamenk
Clone the jenkinsci docker repository and build your custom jenkins image including build tools you need
Run build jobs in docker containers
I used option 3 with success just recently:
Run build jobs inside docker containers (look into Jenkins pipeline plugin, or just run it from a shell step)
Each build container has a single responsibility and provides all the tools your build environment needs
Support for different tools and versions is unlimited; new technologies can be added in no time
Another (more tricky) alternative is it to use Docker Containers for your tools.
I can recommend the following two articles:
https://jenkins.io/blog/2016/08/08/docker-pipeline-environments/
https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/

Resources