Skip to content

Commit

Permalink
[Collect Only PR check] Force remove "sonic-mgmt-collect" container b…
Browse files Browse the repository at this point in the history
…efore "docker run" (#16509)

The "Collect Only" PR check needs to spawn a new "sonic-mgmt-collect" container to run
the check. If the agent instance is not brand new, it could already has a "sonic-mgmt-collect"
container running. Then creating another "sonic-mgmt-collect" container would run int
conflicts. The error log is like below:

+ sudo docker run --rm -dt --name sonic-mgmt-collect -v /agent/_work/1/s:/var/src/sonic-mgmt sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt:latest /bin/bash
docker: Error response from daemon: Conflict. The container name "/sonic-mgmt-collect" is already in use by container "767ed83745baf81fa476bacc22302bce5c111c9afc1f7a5d8e763a996fb776e1". You have to remove (or rename) that container to be able to reuse that name.

This change added a step to always force remove "sonic-mgmt-collect" container. Then the
subsequent step of creating such container will not run into name conflicting issue.

Signed-off-by: Xin Wang <xiwang5@microsoft.com>
  • Loading branch information
wangxin authored Jan 22, 2025
1 parent 233dd79 commit 812d782
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion .azure-pipelines/pytest-collect-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ steps:
set -x
sudo docker pull sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt:latest
sudo docker rm -f sonic-mgmt-collect || true
sudo docker run --rm -dt --name sonic-mgmt-collect \
-v $(System.DefaultWorkingDirectory):/var/src/sonic-mgmt \
sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt:latest \
Expand Down

0 comments on commit 812d782

Please sign in to comment.