Using Multiple Docker Images with Gitlab CI

April 2, 2017

I use Gitlab to store nearly all of my source code. One of the features that I love about Gitlab is Gitlab CI, the built-in, fully integrated CI/CD feature.

The CI/CD feature uses Docker to run your custom/arbitrary commands in. You can specify custom Docker image for Gitlab CI to use using the image: tag.

One very handy feature worth mentioning is that you specify different Docker image for each stage of the build.

For example, if your CI/CD process has three steps: build, test, deploy. You can specify different image for each stage:

  • build: node:6-wheezy
  • test: node:7-wheezy
  • deploy: mikesir87/aws-cli

(Example above was arbitrarily written for illustration purposes only. You can pick any Docker image from either private or public registry. You can have as many steps as possible)

.gitlab-ci.yml example:

This way, you can run different sets of commands that require different sets of dependencies.

Of course, you can always build your own docker image.

Always be cautious when using community-built docker images – only use those that you TRUST.

Author
Ryan Harijanto

Head of Engineering. Former Sr. Engineer @Netflix , @HotelTonight , @Shutterstock. Previously a Senior Systems Engineer at Netflix, currently technology advisor and board member for emerging companies. Diverse technological knowledge and understanding of various industries.

Leave a Reply

Your email address will not be published. Required fields are marked *