Child pages
  • Docker Integration plugin
Skip to end of metadata
Go to start of metadata

TeamCity Docker integration plugin provides various features which facilitate working with Docker under TeamCity.

Supported environments

So far TeamCity docker support can run on Mac/Linux build agents. It uses 'docker' executable on the build agent machine, so it should be runnable by build agent user. 

Features

Docker version

Build agent with the plugin registers 'docker' property in the format like 1.13.1. If the build agent has docker-compose installed, it's version is also put into 'docker-compose' property.

Docker build feature

During the build, docker events will be monitored, and such operations as docker pull, docker run will be detected. After the build, the information about various Docker-related operations will be available on a separate Docker Images Info tab.

Docker.Build runner

A simple helper for building Docker images as a separate build step.

Also, when Dockerfile is present in the corresponding VCS repository, Docker.Build runner will be offered as an option during the step of build configuration runners auto-detection.

Docker.Compose build runner

This build runner allows to start docker-compose build services, and shut down those services at the end of the build. To use this feature, you need a docker-compose YAML file with a description of services to be used during the build. 

This feature can be used only if you install both docker and docker-compose on the build agents.

The path of the docker-compose.yml file should be relative to the checkout directory. 

When using docker-compose with images which support HEALTHCHECK, TeamCity will wait until 'healthy' status of all containers, which support this parameter.

If docker-compose start was successful, TeamCity agent will register an environment variable TEAMCITY_DOCKER_NETWORK which will contain the name of the docker-compose default network. Also, this network will be passed transparently to the Docker Wrapper used by further build steps (see below).

Docker Wrapper

For some runners, it is possible to specify a docker image which will be used for running the build step.

Technically, the command of the build runner is wrapped in a shell script, and this script is executed inside a docker container with docker run command. All details about started process, text of the script etc. are logged into the build log.

Checkout directory and most build agent directories are mapped inside docker process, and TeamCity passes most environment variables from the build agent into docker process.

Before build runner script, TeamCity runs 'umask 0' command, thus all files created by the build script will have 'everyone can write' permission set (0777). This mitigates a possible problem when files from docker container are created with 'root' ownership and they cannot be removed by build agent later. 

If the process environment contains a variable TEAMCITY_DOCKER_NETWORK this network is passed to the started docker run command with --network switch. 

It is possible to provide extra parameters for docker run command, for instance, provide an additional volume mapping. It is also possible to prohibit some environment variables from passing inside docker process.

docker pull

Icon

If you need to always run your build on the latest version of the specified image (TW-50360), you should add a command line runner build step with a command like 

docker pull myImage || docker pull myImage || docker pull myImage


Currently supported build runners

  • Command line runner
  • Ant runner (only when plugin is used with TeamCity 2017.2)
    • Requires java inside docker image in PATH, like openjdk:8u121
  • Gradle runner
    • Requires java inside docker image in PATH, like openjdk:8u121
  • Maven runner
    • Requires java inside docker image in PATH, like openjdk:8u121

Docker Disk Space Cleaner

The plugin provides an extension to Free Disk Space build feature which runs "docker system prune -a" command when there is enough disk space at the beginning of the build. The command is run only as the last resort, if all other cleaners did not manage to free enough space.



  • No labels

2 Comments

  1. From where do I download this plugin?

    1. Hello Luis,

        The plugin has not been released to the public yet, we're doing the internal testing. Please vote for https://youtrack.jetbrains.com/issue/TW-38023 to get notified when it is available.

        Thanks,