[Docker] The container name @@@ is already in use by container ... 해결 방법
문제 상황
Gitlab CI/CD Pipeline 중에서 잘 되었던, 잘 될 수밖에 없는 절차에서 에러가 났다.
하여 에러난 부분의 로그를 살펴보니
docker: Error response from daemon: Conflict. The container name "NAME" is already in use by container "CONTAINER ID". You have to remove (or rename) that container to be able to reuse that name.
의 문제가 발생하고 있었다.
docker ps로 컨테이너들을 살펴보니 이미 사용되고 있다던 CONTAINER ID 가 없었다. (여기서부터 이상했던 것인데...)
그래도 해당 ID 값으로 컨테이너를 삭제하고, 이미지도 삭제해보고,
다시 실행해보아도 그대로여서 이것저것 해보았다. 💦
해결 방법
1. 전체 Container 확인하기
$ docker ps -a
2. 문제 관련 Container들 삭제하기
$ docker rm [Container ID]
나의 경우, Exit이거나 Created인 상태였는데도
docker: Error response from daemon: Conflict. The container name "/NAME" is already in use by container "CONTAINER ID". You have to remove (or rename) that container to be able to reuse that name.
를 발생시키는 원인이었다.
해당 컨테이너들을 삭제해주었더니 해결됐다👏
참고:
https://stackoverflow.com/questions/31697828/docker-name-is-already-in-use-by-container
Docker - Name is already in use by container
Running the docker registry with below command always throws an error: dev:tmp me$ docker run \ -d --name registry-v1 \ -e SETTINGS_FLAVOR=local \ -e STORAGE_PATH=/registry \ -e
stackoverflow.com
https://elisom.tistory.com/entry/Docker-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0
[Docker] 도커 이미지, 컨테이너 추가·삭제·확인·실행·정지하기
Docker image 확인하기 $ docker images 동작 중인 Container 확인하기 $ docker ps 동작 중이지 않은 Container 확인하기 $ docker ps -a Docker image 받아오기 $ docker pull [Git URL] Container 실행시키기..
elisom.tistory.com