Docker

Docker error:You have to remove (or rename) that container to be able to reuse that name.

Naranjito 2021. 11. 23. 11:18
  • Docker Error

ERROR: for es01  Cannot create container for service es01: Conflict. The container name "/es01" is already in use by container "7053980c5df7207f8629e57a7b573fd7fc38b7e32e49a1b40e42c8f33a11f188". You have to remove (or rename) that container to be able to reuse that name.

 

  • Cause

I had same name container.

$ docker ps -a
CONTAINER ID   IMAGE                                                  COMMAND                  CREATED          STATUS                    PORTS                                       NAMES
75fecccb0357   docker-compose_jupyternotebook_jupyter                 "/bin/sh -c 'jupyter…"   12 seconds ago   Up 11 seconds             0.0.0.0:8888->8888/tcp, :::8888->8888/tcp   docker-compose_jupyternotebook_jupyter_1
f620576d4bb1   workspace_jupyter                                      "/bin/sh -c 'jupyter…"   6 days ago       Exited (137) 6 days ago                                               workspace_jupyter_1
7053980c5df7   docker.elastic.co/elasticsearch/elasticsearch:7.15.1   "/bin/tini -- /usr/l…"   6 days ago       Exited (137) 6 days ago                                               es01

 

  • Solution

Remove that container.

$ docker-compose down

...

$ docker rm -f es01
es01

$ docker rm -f workspace_jupyter_1
workspace_jupyter_1

And then, build again.

$ docker-compose up --build
Creating network "docker-compose_jupyternotebook_elastic" with driver "bridge"
Building jupyter
[+] Building 2.2s (14/14) FINISHED                                    

...

Creating es01                                     ... done
Creating docker-compose_jupyternotebook_jupyter_1 ... done

...