I use jib plugin to create image, while docker-compose needs Dockerfile. How can i Link already made image by jib to my docker-compose so it can build my backend in process?
gradle jibDockerBuild && docker-compose up
is a reasonable workaround. You just need to set a correct image name in the image:
property (instead of build:
) in docker-compose.yml
. The jibDockerBuild
command will be almost no-op (barring the time needed to push an image to your Docker daemon) when there is no change to your app. When you make a change, Jib will build a new image and docker-compose
will use it. Of course, if you don't have to rebuild the image by Jib, docker-compose up
alone will suffice, which will just use the current image in your Docker daemon cache.
Another option: pushing to and pulling from a registry (whether local or remote) with gradle jib && docker pull <your image> && docker-compose up
may be faster if your image is large and you have decent network bandwidth. (This is because Docker Engine API has limited capability compared to Docker Registry API; Jib has to stream an entire image to a Docker daemon with jibDockerBuild
.
jibDockerBuild
, Jib directly pushes an image to your local Docker engine. It doesn't create a tarball. Let's say you did -Djib.to.image=example.com/foo/image
. Then in your docker-comose.yml
, you just say image: example.com/foo/image
without build: .
. Docker Compose will use the image in your local Docker engine. If example.com/foo/image
doesn't exist in your Docker daemon, Docker Compose will try to download it from a remote registry (and fail because the server example.com
doesn't have the image). –
Jugulate docker-compose.yaml
anywhere you like. spring-boot:build-image
is Spring's way to building an image and doesn't use Jib. spring-boot:build-image
produces a very inefficient image, so you shouldn't use it when you configured Jib. Use Jib's jib:build
or jib:dockerBuild
instead. –
Jugulate docker-compose up
will work only for the first time. If you want to refresh the container with the new image you have to add --force-recreate
. Also, the docker-compose
is not supported anymore and the docker compose
should be used instead. –
Oteliaotero © 2022 - 2025 — McMap. All rights reserved.