Search code examples
amazon-web-servicesdockerteamcityamazon-ecr

TeamCity: push docker image to AWS ECR


Running TeamCity 2019.1.4 with one server and three separate agents. Both agents and the server are running in their respective server/agent containers in separate EC2 instances. I want the build artifact (docker image) to be pushed to the ECR. Permission is configured via IAM role. I am getting Unauthorized error when pushing/pulling. Manually pulling image from the agent EC2 host works. But manually pulling from within the agent EC2 container gives the same error. How do I configure the TeamCity agent container to identify itself as the host machine?

PS: An option I am trying to avoid is to run TeamCity agents in a classic mode (manual installation) which will most likely work.


Solution

  • Do the following:

    • in TeamCity project configuration, add ECR connection.
    • then, in the build configuration, add build feature, add "Docker Support".
    • make sure the choice "Log in to the Docker registry before the build" is checked and you choose the ECR connection from the project configuration.