Automating Docker Image Builds (with Gitlab CI)

April 10, 2017

As mentioned in my previous post, I use Gitlab to store nearly all of my source code. Including my Docker image repositories.

I maintain my own Docker Image that I use to run my Gitlab CI build commands (it has the AWS CLI, NodeJS, and few other things).

I use Gitlab CI to automatically build, test, and push the image do Docker Hub whenever I commit new changes.

Here’s what my .gitlab-ci.yml looks like:

You can set the environment variables in:

and scroll down to:

Gitlab CI Runner Setup

Make sure your Gitlab CI Runner is running in privileged mode:

In your /etc/gitlab-runner/config.toml file (inside your Gitlab CI Runner server, which is usually the same server as the server running your Gitlab server), make sure privileged = true

Security Warning: privileged mode will allow your Docker containers to gain privileged access to the host. Only use this Gitlab CI runner with repositories you trust.

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 *