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
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 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.
- Enable the
- 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 #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.