Recently I faced an issue with my Azure DevOps self hosted container agents. They could not checkout the git repositories and the build stopped due to the default timeout of 60 minutes per run.
This happened for multiple builds, as a result I had to investigate the reason behind this error.
By checking the logs inside the container on the C:\agent\_diag folder I could recognize an error message like the below:
A session for this agent already exists.
Agent connect error: The task agent xxx already has an active session for owner xxx.. Retrying until reconnected.
By searching online, I figured out that this is a reported bug on previous agents versions. In order to resolve, I updated and reconfigured the agent. You can update the agent, either from the GUI or by creating a new container and installing the latest version of azure devops agent.
In order to reconfigure the agent I first took an interactive shell on it.
docker exec -it agent-name powershell.exe
Then inside C:\agent run the below commands.
Reconfigure the agent
This is a temporary fix for your agent. If the problem persists you should open a support ticket on Microsoft to troubleshoot the issue.