0

I can not create a certain docker container because jenkins tells me that the name is allready in use.

docker run -d --name branchtest_container -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro branchtest_image
docker: Error response from daemon: Conflict. The container name "/branchtest_container" is already in use by container "256869981b65b979daf203624b8c0b5a8e475464a647814ff12b32c322844659". You have to remove (or rename) that container to be able to reuse that name.

I allready tried finding or deleting this container, but i am not able to do so:

jenkins@jenkins-slave4oed:~$ docker rm 256869981b65b979daf203624b8c0b5a8e475464a647814ff12b32c322844659
Error response from daemon: No such container: 256869981b65b979daf203624b8c0b5a8e475464a647814ff12b32c322844659

jenkins@jenkins-slave4oed:~$ docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
jenkins@jenkins-slave4oed:~$

The container gets build via jenkins, and in different build there is allways the same container id that gets disclaimed as in use. We have eight different jenkins nodes and this job works on seven of them, creating and removing docker images with that name.

What can be done to remove this "ghost" container? Allready tried without success:

systemctl restart docker
docker rm $(docker ps -aq --filter name=branchtest_container)
docker container prune
Frankenstein
  • 653
  • 9
  • 18

1 Answers1

0

You can not just remove running container. You need to stop it at first.

To get all containers run:

docker ps -a

To remove container:

docker stop $(docker ps -a -q --filter name=branchtest_container) || true
docker rm -f $(docker ps -a -q --filter name=branchtest_container) || true
Dmitriy Tarasevich
  • 1,082
  • 5
  • 6