Docker Community Forums

Share and learn in the Docker community.

Cannot create container as it already exists

I get the following error when I try to run

docker-compose up -d

ERROR: for prj-redis Cannot create container for service redis: Conflict. The container name "/prj-redis" is already in use by container "5...a8". You have to remove (or rename) that container to be able to reuse that name.

Although the error message is very clear, the problem is that the already in use container is the one I want to use.
How can I “connect” the container name to that container so that it run up with no problem? What is causing this kind of error?

Thanks in advance

I too am having this issue. So, far, the best answer I can find is utilizing the docker-compose stop command to stop and not remove all running containers. See SO answer here: https://stackoverflow.com/questions/49278020/docker-cannot-start-service-as-already-exists