Stella Miller
Stella Miller

Reputation: 31

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.

Here is a screenshot of what it shows on Docker for me.

Upvotes: 3

Views: 2013

Answers (1)

cam
cam

Reputation: 5198

This failure can happen when a container with the same name is no longer running. Your second command docker cp repo:/git/getting-started/ . failed because a container repo was not created properly in the previous step.

You can check what containers are running on the Docker Desktop Containers/Apps page. Below shows the container named csci104 and tagged from the repo usccsci104/docker:20.04 is running:

Docker Desktop Containers and Apps Page Screenshot

Or you can check running containers with the docker ps command, docs here.

I would recommend you try to clear unused containers with docker system prune command or explicitly remove the repo container so you can try again:

# 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

Then, retry running the docker run command and if this succeeds, retry the docker cp command.

Upvotes: 1

Related Questions