Build a production custom docker image of grafana from it github - docker

I need make some changes on the code of grafana an them compile it.
I have downloaded the github repo, made the changes and rum
docker build -t custom-grafana -f Dockerfile .
As you can see many site over internet.
The problem is that compile in this way make a build from v7.5.0-dev version of grafana, and I need use the latest version...
I cant find de way to compile a custom grafana code using the latest version of gfrafana code.
I need help...
Thank you!

If you have cloned the grafana repository from GitHub than you must checkout the branch/tag that you want to compile.
The latest version at the moment is 7.5.6, you can just check it out before building the docker container.
git checkout v7.5.6

Related

Is there any way to mention message for each image version in dockerhub

I am just curious is there any way to pass message in docker push or any docker command which can be seen in docker hub like git commit -m "...".
I want to maintain an docker image which can be used with specific versions of application code so I have to write small message for each version of container about supported code version.
No, you could link your dockerhub repository with github, create release on github per tag and explain changes.
i.e.
Rancher server: https://hub.docker.com/r/rancher/rancher/tags & https://github.com/rancher/rancher/releases

How to tell the software version under a tag on Docker hub

I am quite newbie in docker, and I am trying to find the way to tell version for a docker hub tagged image.
For instance, the jenkins/jenkins:lts-latest image, listed here https://hub.docker.com/r/jenkins/jenkins/tags/, what image version does actually aliase? And how can I infer the correspondent dockerfile/branch in jenkins repo?
I tried with docker search but I couldn't. I tried also to find a clue in the official Jenkins github dockerfile repo: https://github.com/jenkinsci/docker, but I don't see any bindung tag or anything that gives me a hint on the source of the image
Another example, I have a Kubernetes cluster, and when I check my Nexus pod, I see likewise that the image is defined as sonatype/nexus3:latest.
In this case at least I have the imageID: docker-pullable://sonatype/nexus3#sha256:434a2564aa64646464afaf.. but once again I don't know how to map it to the actual version of the software
For the repo you asked, the answer is No.
When setup repo on dockerhub, there are two kinds of options for user to choose as follows:
1) Create Repository:
In this way, dockerhub just create a repo for user, and user need to build his own image on local server, tag it, and push it to dockerhub.
When user push his image to dockerhub, no additional information about the source version will be appended, so can't get any source map from dockerhub.
jenkins/jenkins, just this kind of repo.
2) Create Automated Build
In this way, dockerhub will fetch the code from github or bitbucket, and build the image on its cloud infrastructure, so it will know exactly what source commit is for current docker image.
jenkins/jnlp-slave, just this kind of repo.
Then, you can click its Build Details on the web page, click into one link, e.g. 3.26-1-alpine, you will see log mentioned 0a0239228bf2fd26d2458a91dd507e3c564bc7d0 is the source commit.
To sum up, for the repo you mentioned in the question, they are not Automated Build, so you cannot get the map for the image & source code, but if you happen to find a repo in dockerhub which is Automated Build later & want to know the map, then you can.
As long as I understand your question, you are trying to tag the docker image exact with same version as of your software version. For that I use to create image tag:
$ export VERSION="2.31-b19"
$ docker tag "<user>/<image>:${VERSION}" "<docker_hub_user>/<repo>:latest"
If this is not the case. Please explain your use case a bit more so that we can provide you a better workaround.

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.

Trigger automatic build on dockerhub when some package is updated in official repository

If I have the automated build set up on DockerHub, for instance, based on ubuntu:yy_mm image and in its Dockerfile I install some package foo-bar-ng through the apt-get, how can I set up the image to be automaticaly rebuilt when the package is updated in Ubuntu repository?
Right now the only approach I see is to develop and spin up separate private service for myself which will monitor the package version in official Ubuntu repository and trigger the rebuild by "Built triggers" DockerHub feature that is available in automatic build settings:
Trigger your Automated Build by sending a POST to a specific endpoint.
For instance, here question about how can new packages be monitored in specific Ubuntu repo.
(Made this as an answer - let the community vote on it and, especially, provide better answer if there is any)

docker run git checkout doesn't fetch changes in the branch?

Why RUN git checkout -b mybranch switch to the branch but the content remain the one fetched from the master branch?
The whole point of Docker is that it only rebuilds the part of an image that has changed. It has no way of knowing that the content in the repo has changed, all it knows is that is already has a cached image "slice" for this step in the Dockerfile. So it uses the image it previously built.
As Mark notes, you can force a regeneration using --no-cache. Another option is to have a source code container that is always built using --no-cache which you add volumes to and then use that code via those volumes in a different container (look at 'volumes from' for docker-compose). Then you always get the changes in the repo, as it is built every time from scratch. You may want to look into 'docker-compose' for this sort of work.
When you run docker build look carefully at the output. When it has a cached version of a step it will say as much. When it has to build it, it will also note that.
Have you tried running your build with the "--no-cache" option?
I'd also recommend reading the following:
https://ryanfb.github.io/etc/2015/07/29/git_strategies_for_docker.html
Finally, do you really need to run git within your build? Personally I use Jenkins that runs my build within a workspace that is separately checked out from git.

Resources