This article explains how to run a Docker image locally of a Travis CI build environment. Excellent tool for troubleshooting build issues - without committing changes to your repository.

---
title: Run Travis-CI Builds Locally
subtitle: Running a Container Based Docker Image Locally
author: Jon LaBelle
date: September 15, 2018
source: https://docs.travis-ci.com/user/common-build-problems/#running-a-container-based-docker-image-locally
notoc: false
---

1. **Download and install Docker:**

    - [Windows](https://docs.docker.com/docker-for-windows/)
    - [OS X](https://docs.docker.com/docker-for-mac/)
    - [Ubuntu Linux](https://docs.docker.com/engine/installation/linux/ubuntulinux/)

2. **Choose a Docker image:**

    Select an image on [Docker Hub](https://hub.docker.com/u/travisci/) for the
    language ("default" if no other name matches) using the table below:

    | language |                                   Docker Hub image                                   |
    |----------|--------------------------------------------------------------------------------------|
    | android  | travisci/ci-amethyst:packer-1512508255-986baf0                                       |
    | erlang   | travisci/ci-amethyst:packer-1512508255-986baf0                                       |
    | haskell  | travisci/ci-amethyst:packer-1512508255-986baf0                                       |
    | perl     | travisci/ci-amethyst:packer-1512508255-986baf0                                       |
    | default  | travisci/ci-garnet:packer-1512502276-986baf0                                         |
    | go       | travisci/ci-garnet:packer-1512502276-986baf0                                         |
    | jvm      | travisci/ci-garnet:packer-1512502276-986baf0                                         |
    | node_js  | travisci/ci-garnet:packer-1512502276-986baf0                                         |
    | php      | travisci/ci-garnet:packer-1512502276-986baf0                                         |
    | python   | [travisci/ci-python:packer-1490914243](https://hub.docker.com/r/travisci/ci-python/) |
    | ruby     | travisci/ci-garnet:packer-1512502276-986baf0                                         |

3. **Start a Docker container detached with /sbin/init:**

    ```bash
    docker run --name travis-debug -dit travisci/ci-python:packer-1490914243 /sbin/init
    ```

4. **Open a login shell in the running container:**

    ```bash
    docker exec -it travis-debug bash -l
    ```

5. **Switch to the travis user:**

    ```bash
    su - travis
    ```

6. **Clone your git repository into the home directory:**

    ```bash
    git clone --depth=3 --branch=master https://github.com/jonlabelle/SublimeJsPrettier.git
    ```

7. **Check out the commit you want to test** (optional):

    ```bash
    git checkout 6b14763
    ```

8. Manually **install dependencies**, if any.

9. Manually **run your Travis CI build** command.