Docker in Continuous Integration: Part I
Using an existing Docker image is the path to take when you want to override Shippable's default image or set specific options for booting up the default container in CI.
Join the DZone community and get the full member experience.Join For Free
this blog series covers three docker in continuous integration (ci) scenarios. a ci process combined with immutable docker images expedites delivering software changes. the three scenarios covered in this series are:
- use an existing docker image.
- build your own docker image.
- push a docker image to a registry of your choice.
in this blog, i'll cover the first scenario.
use an existing docker image in your ci process with either of the following two options. we'll look at each options, see when to use them, list out steps you should take, and give examples.
- shippable's default docker image.
- your own custom docker image.
shippable's default docker image
when to use this option
- your ci process doesn't use docker.
- shippable's default docker images fulfills your ci process requirements.
specify the language, the version (optional), and the service (optional) that you need in the
file. based on your input, the platform automatically chooses the best default image for your ci process.
language: node_js node_js: - 0.12 build: ci: - npm install
use this tutorial to run continuous integration for a simple node.js application. this example pulls a default node.js docker image for the ci process.
your own custom docker image
specify your private docker image to run your build. shippable will start the build container from your docker image and run the ci process.
when to use this option
- override shippable's default image with your own custom docker image.
- set specific options for booting up the default build container for the ci process.
language: node_js node_js: - 0.12 build: pre_ci_boot: image_name: abhijitkini/testimage image_tag: latest pull: true env: foo=bar options: "-e home=/root" ci: - npm install integrations: hub: - integrationname: docker-hub type: docker branches: only: - master
- follow along by forking this node.js sample application (sample_nodejs) , available for free on github. alternatively, follow along based on your own repo. if you have never used shippable, take 30 minutes to complete the getting started tutorial .
- log into shippable using your github credentials.
- create an integration on shippable to your image registry (docker hub used in this example).
shippable.ymlfile compared to the above sample. replace the following values.
abhijitkini/testimagewith your docker-hub-username/docker-hub-image-repo. for google container registry or amazon ec2 container registry, refer our documentation .
latestwith the tag of the image you want to pull.
pull: set to
truefor the image to be pulled from the docker registry.
env: specify environment variables you want inside your build container.
options: enter docker options for use in the
docker runcommand. you can also include home environment variable as shown, if it isn't set in your image.
docker-hubwith the name of the docker integration you created in step 4.
dockerthis value specifies it is a docker registry integration.
branches(optional): skip this for your integration to be applicable to all branches. in this example, it is applicable only to the
shippable.ymlchanges, which automatically triggers a build on shippable.
- shippable pulls your docker image from docker hub and uses it in the ci process. a successful build is shown below:
you can combine each option with push a docker image to a registry of your choice (scenario #3) in your ci process. we'll go over this combination of scenarios in a later post.
you can use shippable's default docker images in your ci process when you don't use docker or the default images fulfill your requirements. use your own custom docker image in your ci process when you want to override the default images or set specific options to boot the build container.
in the next blog, we'll go over scenario #3: build your own docker image.
Published at DZone with permission of Manisha Sahasrabudhe, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.