Azure Batch: Docker error: Conflict the Container name is already in use by container

Demeusy, Valentin 5 Reputation points
2026-06-24T13:50:07.4066667+00:00

Hello,

When I submit long runnging tasks (~8hours) in Azure Batch I get an error after some time. At first, everything seems fine, the job is running normally, I see the logs in stdout.txt. After a while, the task is in failed state, the stdout has been cleared and the stderr indicates the following:

docker: Error response from daemon: Conflict. The container name "REDACTED" is already in use by container "50f2aa....e47f38c76672c1c09". You have to remove (or rename) that container to be able to reuse that name.

It looks like the task has tried to restart while it was still running but I don't know how it's possible.

I am using Batch Shipyard to submit the jobs. Pool is running Ubuntu 24 Node size: standard_d2_v3 I only use dedicated node. Autoscale is on with a simple task based formula (but I see the same error without the autoscale). Task is using docker image stored in Azure private repository.

Thank you for your help.

Azure Batch
Azure Batch

An Azure service that provides cloud-scale job scheduling and compute management.


1 answer

Sort by: Most helpful
  1. Alex Burlachenko 25,030 Reputation points MVP Volunteer Moderator
    2026-06-24T14:32:41.44+00:00

    Demeusy, Valentin hi, thx for sharing urs issue here at Q&A portal,

    Looks like Batch/Shipyard is trying to start the task container again, but Docker still has the old container with the same name on the node.

    That usually happens when the task gets interrupted/retried, the node reboots, Docker daemon restarts, Batch thinks the task needs to start again, but the previous container wasn’t removed cleanly. Then Docker refuses bc container names must be unique.

    Since it happens after some hours, I’d check task retry count, max wall clock time, node reboot events, Docker daemon logs, and Batch node events. If stdout gets cleared, that’s another clue the task attempt may have restarted, not just crashed inside ur code.

    Quick thing: make sure the container is run with auto-remove behavior or unique container names per attempt if Batch Shipyard lets u set it. If the name is fixed per task, retries can collide with stale containers.

    On an affected node, before cleanup, run

    docker ps -a

    docker inspect <container-id>

    journalctl -u docker --since '10 hours ago'

    Worth checking Batch task execution info too, esp retryCount, exitCode, failureInfo, and previous attempts https://learn.microsoft.com/en-us/azure/batch/batch-retry-task

    Batch Shipyard may also be part of the story here, bc it generates/manages Docker names. If it uses deterministic names and the cleanup path fails, long-running retries can hit exactly this.

    Workaround rn: disable/limit retries while testing, use unique task IDs/container names, or add a cleanup step that removes the old container before start:

    docker rm -f <container-name> || true

    Not beautiful, but it proves the stale-container theory fast.

    My guess: task/node restart + stale Docker container, not Azure Batch randomly running the same task twice on purpose.

    rgds,

    Alex

    &

    If my answer was helpful pls mark it and additional thx if u follow me at Q&A portal
    

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.