TeamCity 2019.1 Help

Docker Wrapper

TeamCity provides the Docker Wrapper extension for Command Line, Maven, Ant, Gradle, and since TeamCity 2018.1, .NET CLI (dotnet) and PowerShell runners. This extension allows running a build step inside the specified Docker image. Each of the supported runners has the dedicated Docker settings section.

Requirements

The integration requires Docker installed on the build agents. Docker Compose also needs to be installed to use the Docker Compose build runner.

Supported Environments

TeamCity-Docker support can run on Mac, Linux, and Windows build agents. It uses the docker executable on the build agent machine, so it should be runnable by the build agent user.

Since version 2018.2, TeamCity has switched from Oracle Java to OpenJDK 8 (by AdoptOpenJDK). All Docker images have been updated to support OpenJDK.

Docker Settings

In this section, you can specify a Docker image which will be used to run the build step. Once an image is specified, all the following options are available:

Setting

Description

Run step within Docker container

Specify a Docker image here. TeamCity will start a container from the specified image and will try to run this build step within this container.

Docker image platform

Select <Any> (default), Linux or Windows.

Pull image explicitly

If the checkbox is enabled, docker pull <imageName> will be run before the docker run command.

Additional docker run arguments

The Edit arguments field allows specifying additional options for docker run. The default argument is --rm, butyou can provide more, for instance, to add an additional volume mapping.

How It Works

Technically, the command of the build runner is wrapped in a shell script, and this script is executed inside a Dockercontainer with the docker run command. All the details about the started process, text of the script etc. are writteninto the build log (the Verbose mode enables viewing them).

The checkout directory and most build agent directories are mapped inside the Docker process.

At end of the build step with the Docker wrapper, a build agent runs the chown command to restore access of thebuildAgent user to the checkout directory. This mitigates a possible problem when the files from a Docker container arecreated with the 'root' ownership and cannot be removed by the build agent later.

If the process environment contains the TEAMCITY_DOCKER_NETWORK environment variable set by previousDocker Compose build step, this network is passed to the started docker run commandwith the --network switch.

Environment Variables Handling

TeamCity passes environment variables from the build configuration into the docker process, but it does not passenvironment variables from the build agent, as they may be not relevant to docker container environment. The list of thepassed environment variables can be seen in Verbose mode in the build log.

Last modified: 19 June 2019