docker - Docker Setup, cannot clone the repository because container name already taken
问题描述
I am really new to Docker and am trying to set it up on my laptop. I am on the "Getting Started" project and am trying to clone the repository, but when I run the code it says Error: No such container:path: repo:/git/getting-started/
It also says Error response from daemon: Conflict.T The container name "/repo" is already in use by container "23b79....."
I tried to use File Explorer to find a folder named "repo" but could not find anything. I am also not sure how to search for that container since it just gives me a large string.
解决方案
当具有相同名称的容器不再运行时,可能会发生此故障。您的第二个命令docker cp repo:/git/getting-started/ .
失败,因为repo
在上一步中未正确创建容器。
Containers/Apps
您可以在 Docker 桌面页面上查看正在运行的容器。下面显示了csci104
从 repo 命名和标记的容器usccsci104/docker:20.04
正在运行:
或者,您可以使用docs heredocker ps
命令检查正在运行的容器。
我建议您尝试使用docker system prune命令清除未使用的容器或显式删除repo
容器,以便您重试:
# this will clear all unused containers you have created
docker system prune -f
# this will remove the /repo container causing docker run command to fail
docker rm -f repo
然后,重试运行该docker run
命令,如果成功,则重试该docker cp
命令。
推荐阅读
- python - Python Scraping 提取船只名称
- python-3.x - 使用 BSoup 解析来自 Python 请求的注释数据
- python - Python:根据给定的单词选择句子并将其导出为 excel
- php - 使用 Laravel Sail 运行 Laravel Dusk 时连接被拒绝
- linux - 如何在远程机器上运行复杂的 awk 命令
- docker - VSCode ACI 部署的 Docker 容器未显示在侧边栏中
- salt-stack - Salt stack:如何使用 Chocolate(状态)设置包安装检查
- javascript - 在 Javascript 中以自然方式添加后,我无法在 asp.net 中获取 Listbox 的值
- python - 如何在 MacOS 上的 Visual Studio Code 中运行 Pytest?
- python - Python 记录器 - 将 STDOUT 重定向到日志文件以及任何调试消息