By continuing to navigate on this website, you accept the use of cookies to serve you more relevant services & content .
For more information and to change the setting of cookies on your computer, please read our Cookie Policy.

Gitlab and Docker - Continuous Integration, Deployment and Continuous Delivery

Continuous integration and continuous deployment has become one of the most common use cases of Docker early adopters.
CI/CD merges development with testing, allowing developers to build code collaboratively, submit it the master branch,
and checked for issues. This allows developers to not only build their code, but also test their code in any environment type
and as often as possible to catch bugs early in the applications development lifecycle.

- An excerpt from Docker

In my previous blog post,  we have configured omnibus Gitlab Installation with CI Enabled, In this blog post, we will see how we can test - build - deploy code using gitlab and docker.


Add a new file ".gitlab-ci.yml" in your local git repository root level and add in following code

    image: <docker-image-to-perform-operations-on>
      - step-1
      - step-2
      - step-3

Note: Steps are shell commands:

If you have CI configured as per my previous tutorial, you should see your project code being tested in docker image you mentioned by executing script section commands.


    image: python:2.7
      - pip install -r requirements.txt
      - python test

The above snippet is used by me generally to run django test cases. This will download python 2.7  Docker image, if it doesn't exist and install requirements.txt [pip packages needed for project] and run command python test. 

Build & Deploy:

You can have them on same server or different based on your choice. If you want to Build or Deploy, the servers you want to use for the purpose, should have all  required packages pre-installed and have gitlab-runner, for gitlab to commence build and deploy, so as many types of environments you have, you need runners on all those servers(test servers, stage servers, production servers.. etc., ). To make sure correct tasks are picked up by correct runners,, you need to add option called tags, which runner looks for[Note; Gitlab runner to listen on which tags will depend on your input during runner configuration.


    image: python:2.7
      - pip install -r requirements.txt
      - python test
      - test

        - pip install -r requirements.txt
        - docker pull <image-name>
        - docker run -itd <image-name>
        - service nginx restart
        - micropyramid-stage

So tags in the gitlab-ci.yml decide on execution of task on server allocated for that particular task.

In general, you can have a single server that can run all test cases and production and staging runners running on respective servers to pick up on tasks to perform to deploy it in respective environments for projects.


Related Links:
Live CI/CD demo - Video and Repository
Enabling container registry in gitlab
Setting up Gitlab omnibus edition - Blog Post and Video

We will Provide Docker Consulting services and Server Maintenance Services. To Know more about our services contact

    Posted On
  • 06 February 2017
  • By
  • Micropyramid

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
How to setup http password authentication with nginx

HTTP Authentication is used to allow access limit to a site or particular directories by validating the username and password. HTTP basic authentication can also ...

Continue Reading...
Automate Django Deployments with fabfile

Fabric is a Python library and command-line tool with the ability to execute commands on a remote server. It is designed to use SSH to ...

Continue Reading...
Configure SSL with LetsEncrypt and nginx

Configuring SSL is beneficial not only for security purpose but also for SEO too.
Linuxsoftware foundation's initiated a program called Let’s Encrypt to give ssl ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties