This blog series covers three Docker in Continuous Integration (CI) scenarios. A CI process combined with immutable Docker images expedites delivering software changes. Shippable makes it easy for you to use Docker images in your CI process, without a separate DevOps tool or code. 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
Use an existing Docker image in your CI process with either of the two options. We'll look at each option, when to use it, steps to take and 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
shippable.yml 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 step-wise 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 mins to complete the getting started tutorial.
- Log in to Shippable using your GitHub credentials
- Enable the 'sample_nodejs' project
- Create an integration on Shippable to your image registry (Docker Hub used in this example)
- Modify the
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
- Commit 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 three) in your CI process. We'll go over this combination of scenarios in a later post.
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 two - "Build your own Docker image".