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.
Since version 2018.2, TeamCity has switched from Oracle Java to OpenJDK 8 (by AdoptOpenJDK). All Docker images have been updated to support OpenJDK.
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:
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,
Additional docker run arguments
The Edit arguments field allows specifying additional options for
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
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.