docker: Error response from daemon: Conflict. The container name "/xx" is already in use


 

使用docker 出現Error response from daemon: Conflict. The container name “***” is already in use
解決方法:
(1)給容器換一個名字, 比如說 docker run -it --name=mycentos2 centos:7 /bin/bash, 可以解決問題.
(2)將原來的容器刪除

查詢當前容器:docker container ls -all

刪除當前容器:docker container rm mycentos(提示: 這一步要確定刪除容器沒問題的情況下, 才可以做)

 

這里有兩個不同的單詞,images和container。其中images很好理解,跟平常使用的虛擬機的鏡像一個意思,相當於一個模版,而container則是images運行時的的狀態。docker對於運行過的image都保留一個狀態(container),可以使用命令docker ps來查看正在運行的container,對於已經退出的container,則可以使用docker ps -a來查看。 如果你退出了一個container而忘記保存其中的數據,你可以使用docker ps -a來找到對應的運行過的container使用docker commit命令將其保存為image然后運行。

回到之前的問題,由於image被某個container引用(拿來運行),如果不將這個引用的container銷毀(刪除),那image肯定是不能被刪除。

所以想要刪除運行過的images必須首先刪除它的container。
———————————————— 

 

針對上面報錯也可以:

docker: Error response from daemon: Conflict. The container name “/mysql” is already in use by container “27e9834dce87b6cac674945d7917ce2f9c52537569420275fd05b3e5e6460070”. You have to remove (or rename) that container to be able to reuse that name.
出現上述的錯誤,是因為docker容器里面已經存在,如果不需要,則刪除。docker rm fb087642b497(該containerID)
如果想要再次使用,使用

docker restart 鏡像名
1
則可以重啟該container容器。
———————————————— 

 

https://blog.csdn.net/qq_36487585/article/details/84327230

https://blog.csdn.net/liuyinfei_java/article/details/88634469


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM