The Docker Wrapper extension allows running a build step inside the specified Docker image.
The extension is available for the following build runners:
Each of the supported runners has the dedicated Docker settings section.
In the Docker Settings section of the build step settings, you can specify a Docker image which will be used to run the build step. Once the image is specified, the following options become available.
Run step within Docker container
Specify a Docker image name as stated in Docker Hub. 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 enabled, the image will be pulled from the Hub repository via
Additional docker run arguments
Allows specifying additional options for the
How It Works
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, and so on, are written into the build log (the Verbose mode enables viewing them).
The build checkout directory and most build agent directories are mapped inside the Docker process.
At the end of the build step with the Docker wrapper, a build agent runs 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 environment variable set by the previous Docker Compose build step, this network is passed to the started
docker run command with the
Environment Variables Handling
TeamCity passes environment variables from the build configuration into the Docker process, but it does not pass environment variables from the build agent, as they may not be relevant to the Docker container environment. The list of the passed environment variables can be seen in the Verbose mode in the build log.