Docker
The Docker build runner allows launching the build
, push
, and tag
Docker commands inside your build.
If a Dockerfile is present in your VCS repository and you create a TeamCity project based on this repository, TeamCity will autodetect it and offer creating a build step using this runner.
Common Settings
This runner is a part of the TeamCity-Docker/Podman integration toolset. Refer to this documentation article for information on software requirements, supported environments, and other common aspects of this integration: Integrating TeamCity with Container Managers.
Available step execution policies are described here.
Docker Command
The runner provides the following settings, depending on the selected command:
Command | Parameter | Description |
---|---|---|
| Dockerfile source | Depending on the selected source, the settings below will vary. Available options are File, URL, and File content. |
Path to file | Available for the File source type: Specify the path to the Dockerfile. The path should be relative to the build checkout directory. | |
Context folder | Available for the File source type: Specify the context for the | |
URL to file | Available for the URL source type: The URL can refer to one of the three kinds of resources: Git repositories, prepackaged tarball contexts, and plain text files. See the Docker documentation for details. | |
File Content | Available for the File Content source type: You can enter the content of the Dockerfile into the field. | |
Image platform | Select <Any> (default), Linux, or Windows. | |
Image name:tag | Provide a newline-separated list of image name:tag(s). | |
Additional arguments for the | Supply additional arguments to the | |
| Remove image from agent after push | If selected, TeamCity will remove the image with |
Image name:tag | Provide a newline-separated list of image name:tag(s). | |
other | Command name | Docker sub-command, like |
Working directory | Specify the build working directory if it differs from the checkout directory. | |
Additional arguments for the command | Additional arguments that will be passed to the |
Running Docker via sudo
You can enforce starting Docker commands on a TeamCity agent via sudo
. Add the teamcity.docker.use.sudo=true
setting in the build agent configuration file or as an agent's system property. On the agent start, the TeamCity agent log will inform you that the sudo
prefix is used to run Docker commands.
To configure the sudoers
file for the sudo
command, use visudo
as follows:
We recommend removing (or commenting out) the Defaults requiretty
line from the sudoers
file to prevent the problem with docker login
.