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.
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.
In this section, you can specify a Docker image which will be used to run the build step.
|Run step within Docker container|
|Pull image explicitly (since TeamCity 2017.2)|
If the checkbox is enabled,
|Additional docker run arguments|
The Edit arguments field allows specifying additional options for
Technically, the command of the build runner is wrapped in a shell script, and this script is executed inside a Docker container with the
docker run command. All the details about the started process, text of the script etc. are written into the build log (the Verbose mode enables viewing them).
The checkout directory and most build agent directories are mapped inside the Docker process, and TeamCity passes most environment variables from the build agent into the docker process.
After the build step with the Docker wrapper, a build agent will run the
chown command to restore access of the buildAgent user to the checkout directory. This mitigates a possible problem when the files from a Docker container are created with the 'root' ownership and cannot be removed by the build agent later.
If the process environment contains the
TEAMCITY_DOCKER_NETWORK variable, this network is passed to the started
docker run command with
It is possible to provide extra parameters for the
docker run command, for instance, provide an additional volume mapping.