dockergithub-actions

The container name "/smoke-test-rabbitmq-1" is already in use by container... - Github Actions


I have an action that spins up some containers to run a smoke test, but the last time it failed, and now every time I try to run the action again, it shows this message. How can I fix it?

Error response from daemon: Conflict. The container name "/smoke-test-rabbitmq-1" is already in use by container "vcd13aceb9c2cc1ab5348b84f8245b4d0fe639471914392ec5dd7a3ec373464". You have to remove (or rename) that container to be able to reuse that name.

The problem with this is that it's a GitHub action, and I can't stop the containers unless I keep executing code. Even testing with 'act' locally, it still generates errors


Solution

  • The easiest workaround is to rename the container, assuming you're running some docker build+run or docker-compose.

    Depending on your workflow, consider post-test removal/pruning in particular with cancelled(), failure() or always(). If you're using self-hosted runners, login to that system and kill the container. For Github-hosted runners, I don't think there is any access to them. You'll have to wait until the default timeout kills the container.