Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to build a docker image without pushing it?

Tags:

concourse

I want to build a docker image in my pipeline and then run a job inside it, without pushing or pulling the image.

Is this possible?

like image 565
Shawabawa Avatar asked Dec 09 '16 13:12

Shawabawa


1 Answers

It's by design that you can't pass artifacts between jobs in a pipeline without using some kind of external resource to store it. However, you can pass between tasks in a single job. Also, you specify images on a per-task level rather than a per-job level. Ergo, the simplest way to do what you want may be to have a single job that has a first task to generate the docker-image, and a second task which consumes it as the container image.

In your case, you would build the docker image in the build task and use docker export to export the image's filesystem to a rootfs which you can put into the output (my-task-image). Keep in mind the particular schema to the rootfs output that it needs to match. You will need rootfs/... (the extracted 'docker export') and metadata.json which can just contain an empty json object. You can look at the in script within the docker-image-resource for more information on how to make it match the schema : https://github.com/concourse/docker-image-resource/blob/master/assets/in. Then in the subsequent task, you can add the image parameter in your pipeline yml as such:

- task: use-task-image
  image: my-task-image
  file: my-project/ci/tasks/my-task.yml

in order to use the built image in the task.

like image 52
Clara Fu Avatar answered Oct 16 '22 16:10

Clara Fu