Docker Registry

144 views
Skip to first unread message

david david

unread,
Apr 23, 2020, 8:18:53 PM4/23/20
to Jib users
Hi,
Could anyone please clarify on the below?

1. How can I pass the my company's private docker registry when I build the image using Jib Gradle to be used for 'to' image parameter?
Below is the command that I'm using . The below creates the image and pushes to the docker registry. However, I see the image both in my local machine and in the company's docker registry.
Is this the correct way to use the company docker registry for pushing the image?


./gradlew build --stacktrace --debug --no-build-cache  --rerun-tasks t <subprojectname>:jibDockerBuild  -Djib.dockerClient.executable=/usr/local/bin/docker

2. I would be using Jib Gradle in my pipeline and wondering whether I need to run as user -root for the Jib Gradle to successfully build the image as 
I'm using the dockerClient? If I use service account, will the jibDockerBuild still work?


Thanks in advance!


Chanseok Oh

unread,
Apr 23, 2020, 9:01:36 PM4/23/20
to Jib users
Hi,

1. Say your private Docker registry's hostname is my.private.registry.com and the registry is listening on port 5000 (i.e, the registry is accepting Docker Registry API calls on 5000). Then your jib.to image reference should start with my.private.registry.com:5000/... For example, my.private.registry.com:5000/my/image/repository. Note that this isn't specific to Jib; Docker CLI, registries, and runtime platforms all follow this standard.

And I am a bit confused by "I see the image both in my local machine and in the company's docker registry", because Jib doesn't simultaneously build an image to a local Docker daemon and to a remote registry. the jibDockerBuild task pushes only to a local Docker daemon and the jib task only to a remote registry.

2. You should not run Jib as root regardless of running jibDockerBuild (local Docker daemon) or jib (remote push). And note that Jib does not even require Docker installed when pushing to a remote registry with jib; in this case, you just need to provide right registry credentials to Jib. And of course, you need Docker on your system if you use jibDockerBuild, because that is the task to build to a local Docker.

david david

unread,
Apr 24, 2020, 4:13:07 PM4/24/20
to Jib users

Thanks for the clarification.
Regarding image being appearing in local machine (docker images command) and on the company's docker registry, is it because of using -Djib.dockerClient.executable=/path/to/docker \ as the parameter to jibDockerBuild? 
I will remove the above -D and run it.
Also, jib.from.image is 'openjdk:alphine'. Since, no registry is passed , it would look in the local machine first and then use the default docker to full the image . Is this correct?
2. I will try with jib command. Thanks for the clarifications.

Thanks,

Chanseok Oh

unread,
Apr 24, 2020, 5:51:48 PM4/24/20
to Jib users

> is it because of using -Djib.dockerClient.executable=/path/to/docker \ as the parameter to jibDockerBuild?

No, `-Djib.dockerClient` just lets you configure the path to the `docker` CLI binary. If you see an image in your local Docker daemon, it's probably because you ever did `jibDockerBuild` or `docker pull` for the image at least once on your machine. And it seems like you did run `jibDockerBuild`. Likewise, as for why you see the image on a remote registry, it's either that you ran the `jib` task or you did `docker push` to push the locally available image to the registry. Or it could have been that another user pushed the image already.

> I will remove the above -D and run it.

You will still run `jibDockerBuild`, so assuming that `docker` CLI is on `PATH`, Jib will build to your local Docker daemon. As I said, it won't push to a remote registry.

david david

unread,
Apr 27, 2020, 11:29:06 PM4/27/20
to Jib users
Thank you so much for the clarification. This really helps. 
Reply all
Reply to author
Forward
0 new messages