Integrating TeamCity with Docker
TeamCity comes with Docker Support, implemented as a bundled plugin.
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.
Parameters Reported by Agent
During the build, the build agent reports the following parameters:
Parameter | Description |
---|---|
| The Docker CLI version |
| The Docker Compose file version if the Docker Compose build step is used |
| The Docker Engine version |
| The Docker Engine OS platform, can have the |
If you are using the Command Line Build step (and not the TeamCity-provided docker steps), these parameters can be used as agent requirements to ensure your build is run only on the agents with Docker installed.
Features
TeamСity-Docker integration provides the following features which facilitate working with Docker under TeamCity:
Docker Support Build Feature
Docker Connection for a Project
Docker Runner
Docker Compose Runner
Docker Wrapper
TeamCity provides the Docker Wrapper extension for Command Line, Maven, Ant, and Gradle runners. Each of the supported runners has the dedicated Docker settings section.
Docker Settings
Docker Disk Space Cleaner
Docker Disk Space Cleaner is an extension to the Free Disk Space build feature ensuring a certain amount of disk space for a build. Since 2018.2 TeamCity performs regular clean-up of Docker images, related to TeamCity:
The TeamCity agent tracks docker images tagged or pulled during builds (the list of images is stored in the
buildAgent/system/docker-used-images.dat
file).During cleanup / freeing disk space, TeamCity agent tries to remove these images if they were not used within 3 days, 1 day, 0 on subsequent attempts to free disk space.
Besides that, TeamCity cleans local Docker Caches using the command:
Since TeamCity 2018.1.2:
docker system prune --volumes
Works for Docker v.17.06.1 or later.Before TeamCity 2018.1.2:
docker system prune -a
Service Message to Report Pushed Image
If TeamCity (for some reason) cannot determine that an image was pushed, a user can send a special Service Message to report this information to the TeamCity server:
For example: